As an alternative to the Black Duck Security Scan Plugin for Jenkins, the Bridge CLI can be downloaded and directly executed in a Jenkins pipeline. It has all the functionality of the plugin, but requires an additional step to download the Bridge CLI.
To use the CLI directly from a pipeline, the correct Bridge CLI Black Duck® SCA parameters must be passed directly inside the pipeline. Furthermore, appropriate access credentials are required to download and use it. Consult the overview page for further details and instructions on use.
To discover more about the Black Duck Security Scan Plugin and what it can do, take a look at the overview page.
The quickstart uses Bridge CLI directly within a Jenkins pipeline to integrate with a GitHub repository. Bridge CLI can integrate with various SCM platforms, e.g. Azure, Bitbucket, GitLab. Adjust the parameters and Personal Access Token (PAT) to match the required SCM platform for integrating with Jenkins. Refer to the reference tables within the Black Duck SCA section for the Bridge CLI parameters needed to integrate with SCM platforms for Fix Pull Requests and Pull Request Comments.
Prerequisites
-
The following reading is recommended before starting this quickstart:
- Admin access to a Jenkins instance.
- A Jenkins agent with a label configured, e.g.
linux64. - Access to a Black Duck SCA server configured with:
- A Black Duck SCA role that allows creation of authentication tokens.
- A Black Duck SCA API token with Read and Write access. This can be created by navigating to from within Black Duck SCA.
- A Personal Access Token (PAT) is required to allow the pipeline to inject Pull Request review comments and raise Fix Pull Requests. The PAT should be generated for the SCM platform that Bridge CLI integrates with from within the Jenkins pipeline, e.g. GitHub, GitLab, Azure, Bitbucket etc.
- The Branch Source plugin must be installed for the appropriate platform to enable Jenkins to integrate with a source code repository and validate pull requests events.
- For security reasons, it is advisable to use Jenkins credentials to store credentials and access tokens. It is recommended that the credentials are added at the appropriate scope level.
- Add the following credentials in Jenkins ()
Credential ID Type Description Example blackduck-sca-api-tokenSecret text Black Duck SCA API Token YOUR_TOKENscm-patSecret text SCM Platform Personal Access Token (e.g., GitHub, GitLab) YOUR_TOKEN - Ensure the following environment variables are set correctly in the pipeline:
Variable Description Example BRIDGECLI_LINUX64URL for downloading Bridge CLI binary https://repo.blackduck.com/artifactory/bds-integrations-release/com/blackduck/integration/bridge/binaries/bridge-cli-bundle/latest/bridge-cli-bundle-linux64.zipBRIDGE_BLACKDUCKSCA_URLBlack Duck SCA server URL https://sca.field-test.blackduck.comBRIDGE_BLACKDUCKSCA_TOKENBlack Duck SCA API token from Jenkins credentials credentials('blackduck-sca-api-token')DETECT_PROJECT_NAMEProject name for Black Duck SCA detection ${env.REPO_NAME}SCM_PATSCM Platform Personal Access Token from Jenkins credentials. Required to inject Pull Request comments and raise Fix Pull Requests. credentials('scm-pat') - The following Bridge CLI parameters are required to inject Pull Request comments and raise fix Pull Requests:
Parameter Description Value Scan type blackducksca.fixpr.enabledRaise Fix PRs for detected vulnerabilities trueFull blackducksca.automation.prcommentEnable PR comments truePR github.repository.pull.numberID of Pull Request to scan $CHANGE_IDNote: Parametergithub.repository.pull.numberis specific to adding Pull Request Comments for GitHub. Refer to the SCM Pull Request comments table within the Black Duck SCA section for the equivalent Bridge CLI parameter required for integrating with other SCM platforms.