Run ScanCode.io into your GitLab CI/CD pipeline.
This integration allows you to automatically scan your code as part of your GitLab pipeline:
- Scans your entire codebase using ScanCode.io
- Generates a comprehensive JSON report
- Archives the results as GitLab pipeline artifacts
- Runs automatically on every build
Create a file named .gitlab-ci.yml in the root of your repository with the following
content:
# GitLab CI/CD Pipeline with ScanCode.io Integration
stages:
- scan
# ScanCode.io Scan Job
scancode_scan:
stage: scan
image: docker:latest
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
script:
- echo "Running ScanCode.io scan..."
# Run the scan and save results
- |
docker run --rm \
-v "$(pwd)":/codedrop \
ghcr.io/aboutcode-org/scancode.io:latest \
run scan_codebase /codedrop \
> scancode_results.json
- echo "Scan completed!"
artifacts:
name: "scancode-results-${CI_COMMIT_SHORT_SHA}"
paths:
- scancode_results.json
expire_in: 30 days
when: alwaysAfter the pipeline completes:
- Go to your pipeline page
- Click on the job name (
scancode_scan) - On the right sidebar, click "Browse" under "Job artifacts"
- Download
scancode_results.json
Or download directly from the pipeline page using the download button.
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:
script:
- |
docker run --rm \
-v "$(pwd)":/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
- GitLab CI/CD Documentation: https://docs.gitlab.com/ee/ci/