The hook prevents pushing commits with issues that Spectral found. It can be enabled at the project or repository level.
- Bitbucket server on Linux (Windows not supported)
- Spectral must be installed on the server: Instructions
- Bitbucket service account with read-only personal access token (optional)
This is required to load custom
.spectral/configuration from the repository. If not set, custom configuration from the repository will not apply.
All configuration is done through environment variables.
|Environment variable||Description||Example value|
|Path to the Spectral binary|
|DSN from SpectralOps, under Settings > Organization|
|Spectral command line arguments|
|The URL to the Bitbucket server|
|The personal access token for Bitbucket (optional, to load |
|The severity of findings allowed before the push is rejected.|
|A custom text to append to the rejection message|
SPECTRAL_CHECK_POLICY supports the following values:
- fail on any issue (default)
- fail on low and above
- fail on medium and above
- fail on high and above
- fail on critical
- always pass
SPECTRAL_DSN="https://[email protected]" SPECTRAL_CHECK_POLICY="fail on high and above" BITBUCKET_SERVER_BASE_URL="https://mydomain.com/bitbucket" BITBUCKET_PAT="TmljZSB0cnkhIEJ1dCB0aGlzIGlzbid0IGEgcmVhbCBvbmUu" SPECTRAL_COMMAND="scan --include-tags base,iac" SPECTRAL_BIN="~/.spectral/spectral"
- Download the Spectral plugin JAR file.
- Open your Bitbucket server UI -> Administration settings
- Click on 'Manage apps' -> 'Upload app'
- Upload the Spectral plugin JAR file
- Enable the hook by going to the project -> Project settings -> Hooks and enabling "Spectral Pre Receive Hook"
- You can also enable the hook for specific repository by going to the specific repository -> Repository settings -> Hooks and enabling "Spectral Pre Receive Hook"
- Timeout for running Spectral
- HTTP connection timeout
- Ignore scanning refs of type tag
- Update app key
- Fix for Could not get .spectral on new branches first push
- Handle multiple refs
- Scan only changed files when pushing a new branch
- [fix] not scanning when a new branch is pushed
- Logging enhancements
Updated 2 days ago