The following guide provides a basic setup example on how to integrate SCANOSS with Jenkins.
This repository contains an example pipeline capable of:
- Cloning a Github repository
- Scanning the source code with the SCANOSS.PY CLI
- Creating an issue in JIRA with copyleft and undeclared components information
Ensure you have all necessary pre-requisites in place and carefully follow the provided instructions.
The following Jenkins plugins need to be installed for the full set of features in the example pipeline:
- Docker Pipeline
- Pipeline Utility Steps
- Generic Webhook Trigger
- Pipeline
- Github Plugin
The SCANOSS Jenkins integrations provides two policies:
-
Copyleft: This policy checks if any component or code snippet is associated with a copyleft license. If such a license is detected, the pull request (PR) is rejected. The default list of Copyleft licenses is defined in the following file.
-
Undeclared: This policy compares the components detected in the repository against those declared in the sbom.json file (customizable through the scanoss.json filepath parameter). If undeclared components are detected, the pipeline will fail.
-
Ensure you have Jenkins installed and configured in your environment. Refer to the official Jenkins documentation for installation instructions.
-
Open the Jenkins dashboard and create a new pipeline job.
-
Configure the pipeline job to use the provided SCANOSS Jenkins pipeline example. The Jenkinsfile contains a sample pipeline script that you can customize according to your project requirements.
The recommended approach to integrate SCANOSS with Jenkins is to load the pipeline from a 'Jenkinsfile' file. To load a pipeline from a file:
- Copy the example
SCANOSS Jenkins pipeline example
from this repository to the root of your repository. - Configure your Jenkins project as follows:
- Pipeline Definition
- Select “Pipeline script from SCM”
- SCM: Git
- Set the following values:
- “Repository URL”
- “Credential” (for private repositories)
- Enter Branch to build
- Set script path as “Jenkinsfile”
- Select “Pipeline script from SCM”
To improve security, credentials should be set in Jenkins credential store.
Navigate to Dashboard > Manage Jenkins > Credentials and select a credential store (e.g., global) and then create a new credential.
Use the same example pipeline, set the following ids:
- jira-credentials: JIRA Token to report issues. Type: user&password
- gh-token: GitHub crendentials to access private repositories. Type: user&password
- scanoss-token: SCANOSS Premium subscription Key. Type: Secret text
The following parameters are available in the example pipeline.
Parameter | Description | Default | Type |
---|---|---|---|
SCANOSS_CLI_DOCKER_IMAGE | SCANOSS CLI Docker Image. | https://ghcr.io/scanoss/scanoss-py-jenkins:v1.19.5 | Pipeline |
ABORT_ON_POLICY_FAILURE | Abort pipeline on pipeline failure. | false |
Pipeline |
SCANOSS_API_URL | SCANOSS API endpoint. | https://api.osskb.org/scan/direct | Pipeline |
SCANOSS_API_TOKEN_ID | SCANOSS API Token ID. | scanoss-token | Pipeline |
SKIP_SNIPPET | Skip the generation of snippets. | false |
Pipeline |
SCANOSS_SETTINGS | Settings file to use for scanning. See the SCANOSS settings documentation | true |
Pipeline |
SETTINGS_FILE_PATH | SCANOSS settings file path. | scanoss.json | Pipeline |
DEPENDENCY_ENABLED | Scan dependencies (optional - default false). | false |
Pipeline |
DEPENDENCY_SCOPE | Gets development or production dependencies (scopes: 'prod' - 'dev'). | '' | Pipeline |
DEPENDENCY_SCOPE_INCLUDE | Custom list of dependency scopes to be included. Provide scopes as a comma-separated list. | '' | Pipeline |
DEPENDENCY_SCOPE_EXCLUDE | Custom list of dependency scopes to be EXCLUDED. Provide scopes as a comma-separated list. | '' | Pipeline |
LICENSES_COPYLEFT_INCLUDE | List of Copyleft licenses to append to the default list. Provide licenses as a comma-separated list. | '' | Pipeline |
LICENSES_COPYLEFT_EXCLUDE | List of Copyleft licenses to remove from default list. Provide licenses as a comma-separated list. | '' | Pipeline |
LICENSES_COPYLEFT_EXPLICIT | Explicit list of Copyleft licenses to consider. Provide licenses as a comma-separated list. | '' | Pipeline |
CREATE_JIRA_ISSUE | Enables JIRA reporting | false |
Pipeline |
JIRA_URL | JIRA URL | '' | Pipeline |
JIRA_PROJECT_KEY | JIRA Project Key | '' | Pipeline |
JIRA_CREDENTIALS | JIRA credentials ID | jira-credentials | Pipeline |
A GitHub webhook automatically triggers the pipeline whenever code is pushed to the repository. Here's how to set it up:
- Navigate to Dashboard > Select your pipeline > Configure
- In the Build Triggers section, select the Generic Webhook Trigger option
- Copy the Jenkins webhook URL that appears
-
Under Post content parameters, add a new variable:
- Variable name:
payload
- Value:
$
- Expression type:
JSONPath
- Variable name:
-
Set up the trigger token:
- http://JENKINS_URL/generic-webhook-trigger/invoke?token=TOKEN
- Configure the Jenkins webhook URL in your GitHub project settings
- For detailed webhook setup instructions, refer to the GitHub webhook documentation
Configure your GitHub repository URL in the project settings:
⚡ Important: Configure these settings carefully to ensure proper webhook functionality
⚡ Important: For private GitHub repositories, it is necessary to provide user credentials. For further details, check Github Documentation.
SCANOSS automatically generates detailed policy check reports that are:
- Uploaded to Jenkins build artifacts
- Integrated with JIRA (optional)
All scan results are stored as build artifacts and include:
Default Report
results.json
- Complete scan results
Conditional Reports
scanoss-copyleft-report.md
- Generated when copyleft licenses are detectedscanoss-undeclared-components-report.md
- Created when undeclared components are found
Note: Conditional reports are only generated when their respective conditions are met during the policy check.
Jenkins stores all SCANOSS scan reports in the run artifacts section for easy access and reference.
⚡ Important: JIRA issues are automatically created only when policy checks fail and JIRA integration is configured.
In order to create issues in JIRA, you must provide Jira credentials. New issues will be created in the name of the specified user.
An API Token is required to integrate JIRA. For further details, check the JIRA Documentation.