As an alternative to the Black Duck Security Scan Plugin, 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 Coverity parameters must be passed directly inside the workflow. Furthermore, appropriate access credentials are required to download and use it. Consult the overview page for further details and instructions on use.
Note: The Black Duck Security Scan Plugin plugin (recommended) can be used for pipelines instead of Bridge CLI by following the quickstart guide. The plugin has equivalent functionality and handles the Bridge CLI download and execution automatically.
To discover more about the Security Scan plugin and what it can do, take a look at the overview page.
Prerequisites
-
The following reading is recommended before starting this quickstart:
- Administrative access to a GitHub repository.
- A Personal Access Token (PAT) is required to allow the pipeline to inject Pull Request review comments. 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 sensitive information.
- Add the following credentials in Jenkins ()
Credential ID Type Description Example coverity-credentialsUsername with password Coverity username and password YOUR_CREDENTIALSscm-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_LINUX64Bridge CLI Download URL https://repo.blackduck.com/artifactory/bds-integrations-release/com/blackduck/integration/bridge/binaries/bridge-cli-bundle/latest/bridge-cli-bundle-linux64.zip BRIDGE_COVERITY_CONNECT_URLCoverity Connect Server URL https://cov.server.blackduck.comBRIDGE_COVERITY_CONNECT_USER_NAMECoverity Connect Username YOUR_USERNAMEBRIDGE_COVERITY_CONNECT_USER_PASSWORDCoverity Connect Password YOUR_PASSWORDSCAM_PATSCM Platform Personal Access Token from Jenkins credentials. Required to inject Pull Request comments. credentials('scm-pat') - The following Bridge CLI parameters are required to inject Pull Request comments:
Parameter Description Value coverity.prcomment.enabledEnable PR comments truegithub.repository.pull.numberID of PR to scan $CHANGE_IDNote: Parametergithub.repository.pull.numberis specific to adding Pull Request Comments for GitHub. Refer to the SCM Pull Request comments table for the equivalent Bridge CLI parameter required for integrating with other SCM platforms.
Coverity requires additional configuration for compiled languages. For languages that use a build system (such as C++, Java, etc.), Coverity must be configured with build and clean commands to capture and analyze the build.
- The instructions below use the Bridge
COVERITY_BUILD_COMMANDandCOVERITY_CLEAN_COMMANDenvironment variables to specify the build and clean commands. - See Using Bridge With Compiled Languages and the Coverity section in Client scan tool parameters for an overview of the various methods available for configuring Bridge CLI to integrate with Coverity to capture and analyze the build for compiled languages.
Instructions
Follow the steps below to configure a Jenkins pipeline that invokes Bridge CLI for full scans and Pull Request scans:
Troubleshooting and support
If a pipeline error is encountered similar to the example below, then the
BRIDGE_COVERITY_LOCAL environment variable should be uncommented in the quickstart code example.Attention: ERROR: Failed to retrieve tool information details: Fetch tool information: received unexpected response status code '500' from Connect API
In this scenario either scan services are not enabled or a Coverity version prior to 2022.3 is deployed. The default behavior is that the pipeline uses the Coverity thin client to upload artifacts, with the analysis performed at the server. Setting the BRIDGE_COVERITY_LOCAL environment variable to true enables the full analysis at the client. Subsequently, the scan and analysis will be performed locally by the workflow. For further details relating to the different Coverity deployment models supported, please refer to Coverity Deployment Architecture.