Run ScanCode.io into your Jenkins CI/CD pipeline.
This integration allows you to automatically scan your code as part of your Jenkins pipeline:
- Scans your entire codebase using ScanCode.io
- Generates a comprehensive JSON report
- Archives the results as Jenkins build artifacts
- Runs automatically on every build
Before you begin, ensure you have:
-
Jenkins installed and running
- Version 2.x or higher recommended
-
Docker installed on your Jenkins agent
- Docker must be accessible to Jenkins
- Test with:
docker --version
-
Required Jenkins Plugins:
- Docker Pipeline Plugin
- Pipeline Plugin
- Git Plugin (if using Git)
Create a file named Jenkinsfile in the root of your repository with the following
content:
pipeline {
agent any
stages {
stage('ScanCode.io Scan') {
steps {
echo 'Running ScanCode.io scan...'
sh '''
docker run --rm \
-v "${WORKSPACE}":/codedrop \
ghcr.io/aboutcode-org/scancode.io:latest \
run scan_codebase /codedrop \
> scancode_results.json
'''
echo 'Scan completed!'
}
}
stage('Archive Results') {
steps {
archiveArtifacts artifacts: 'scancode_results.json', fingerprint: true
echo 'Results archived successfully'
}
}
}
}After the build completes:
- Go to the build page
- Click on "Build Artifacts"
- Download
scancode_results.json
pipeline {
agent any
stages {
stage('Scan') {
steps {
sh '''
docker run --rm \
-v "${WORKSPACE}":/codedrop \
ghcr.io/aboutcode-org/scancode.io:latest \
run scan_codebase /codedrop \
> scancode_results.json
'''
archiveArtifacts 'scancode_results.json'
}
}
}
}This minimal example:
- Runs the scan in a single stage
- Archives the results
Instead of scan_codebase, you can use other ScanCode.io pipelines:
scan_single_package- For scanning a single packageanalyse_docker_image- For scanning Docker imagesload_inventory- For loading existing scan data
Example with a different pipeline:
sh '''
docker run --rm \
-v "${WORKSPACE}":/codedrop \
ghcr.io/aboutcode-org/scancode.io:latest \
run analyse_docker_image docker://alpine:3.22.1 \
> scancode_results.json
'''- ScanCode.io Documentation: https://scancodeio.readthedocs.io/
- ScanCode.io GitHub: https://github.com/aboutcode-org/scancode.io
- Jenkins Pipeline Documentation: https://www.jenkins.io/doc/book/pipeline/