Skip to content

Commit b9fcf34

Browse files
committed
Add support for GitLab CI/CD
Signed-off-by: tdruez <[email protected]>
1 parent 805ea00 commit b9fcf34

File tree

4 files changed

+147
-3
lines changed

4 files changed

+147
-3
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@
33
Run [ScanCode.io](https://github.com/aboutcode-org/scancode.io) pipelines directly
44
from your **GitHub Workflows**.
55

6-
For **Azure DevOps Pipelines** support and setup instructions, see the
7-
[Azure Pipelines documentation](https://github.com/aboutcode-org/scancode-action/blob/main/azure-pipelines/README.md).
6+
# `@aboutcode-org/scancode-action`
7+
8+
Run [ScanCode.io](https://github.com/aboutcode-org/scancode.io) pipelines directly
9+
from your **GitHub Workflows**.
10+
11+
## Supported Platforms
12+
13+
| Platform | Documentation |
14+
|----------|---------------|
15+
| **GitHub Actions** | See [GitHub Actions documentation](https://github.com/aboutcode-org/scancode-action/blob/main/README.md) |
16+
| **GitLab CI/CD** | See [GitLab documentation](https://github.com/aboutcode-org/scancode-action/blob/main/gitlab/README.md) |
17+
| **Jenkins** | See [Jenkins documentation](https://github.com/aboutcode-org/scancode-action/blob/main/jenkins/README.md) |
18+
| **Azure Pipelines** | See [Azure Pipelines documentation](https://github.com/aboutcode-org/scancode-action/blob/main/azure-pipelines/README.md) |
819

920
> [!IMPORTANT]
1021
> The scancode-action is currently in the **beta stage**, and we invite you to

gitlab/.gitlab-ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# GitLab CI/CD Pipeline with ScanCode.io Integration
2+
3+
stages:
4+
- scan
5+
6+
# ScanCode.io Scan Job
7+
scancode_scan:
8+
stage: scan
9+
image: docker:latest
10+
services:
11+
- docker:dind
12+
variables:
13+
DOCKER_DRIVER: overlay2
14+
DOCKER_TLS_CERTDIR: "/certs"
15+
script:
16+
- echo "Running ScanCode.io scan..."
17+
18+
# Run the scan and save results
19+
- |
20+
docker run --rm \
21+
-v "$(pwd)":/codedrop \
22+
ghcr.io/aboutcode-org/scancode.io:latest \
23+
run scan_codebase /codedrop \
24+
> scancode_results.json
25+
26+
- echo "Scan completed!"
27+
28+
artifacts:
29+
name: "scancode-results-${CI_COMMIT_SHORT_SHA}"
30+
paths:
31+
- scancode_results.json
32+
expire_in: 30 days
33+
when: always

gitlab/README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# ScanCode.io GitLab CI/CD Integration
2+
3+
Run [ScanCode.io](https://github.com/aboutcode-org/scancode.io) into your GitLab CI/CD
4+
pipeline.
5+
6+
- [Overview](#overview)
7+
- [Quick Start](#quick-start)
8+
- [Simple Example](#simple-example)
9+
- [Specify Pipeline](#specify-pipeline)
10+
- [Additional Resources](#additional-resources)
11+
12+
---
13+
14+
## Overview
15+
16+
This integration allows you to automatically scan your code as part of your GitLab
17+
pipeline:
18+
19+
- Scans your entire codebase using ScanCode.io
20+
- Generates a comprehensive JSON report
21+
- Archives the results as GitLab pipeline artifacts
22+
- Runs automatically on every build
23+
24+
## Quick Start
25+
26+
### Step 1: Create a .gitlab-ci.yml file
27+
28+
Create a file named `.gitlab-ci.yml` in the root of your repository with the following
29+
content:
30+
31+
```yaml
32+
# GitLab CI/CD Pipeline with ScanCode.io Integration
33+
34+
stages:
35+
- scan
36+
37+
# ScanCode.io Scan Job
38+
scancode_scan:
39+
stage: scan
40+
image: docker:latest
41+
services:
42+
- docker:dind
43+
variables:
44+
DOCKER_DRIVER: overlay2
45+
DOCKER_TLS_CERTDIR: "/certs"
46+
script:
47+
- echo "Running ScanCode.io scan..."
48+
49+
# Run the scan and save results
50+
- |
51+
docker run --rm \
52+
-v "$(pwd)":/codedrop \
53+
ghcr.io/aboutcode-org/scancode.io:latest \
54+
run scan_codebase /codedrop \
55+
> scancode_results.json
56+
57+
- echo "Scan completed!"
58+
59+
artifacts:
60+
name: "scancode-results-${CI_COMMIT_SHORT_SHA}"
61+
paths:
62+
- scancode_results.json
63+
expire_in: 30 days
64+
when: always
65+
```
66+
67+
### Step 2: Access Your Results
68+
69+
After the pipeline completes:
70+
1. Go to your pipeline page
71+
2. Click on the job name (`scancode_scan`)
72+
3. On the right sidebar, click "Browse" under "Job artifacts"
73+
4. Download `scancode_results.json`
74+
75+
Or download directly from the pipeline page using the download button.
76+
77+
## Specify Pipeline
78+
79+
Instead of `scan_codebase`, you can use other ScanCode.io pipelines:
80+
81+
- `scan_single_package` - For scanning a single package
82+
- `analyse_docker_image` - For scanning Docker images
83+
- `load_inventory` - For loading existing scan data
84+
85+
Example with a different pipeline:
86+
```yaml
87+
script:
88+
- |
89+
docker run --rm \
90+
-v "$(pwd)":/codedrop \
91+
ghcr.io/aboutcode-org/scancode.io:latest \
92+
run analyse_docker_image docker://alpine:3.22.1 \
93+
> scancode_results.json
94+
```
95+
96+
## Additional Resources
97+
98+
- **ScanCode.io Documentation:** https://scancodeio.readthedocs.io/
99+
- **ScanCode.io GitHub:** https://github.com/aboutcode-org/scancode.io
100+
- **GitLab CI/CD Documentation:** https://docs.gitlab.com/ee/ci/

jenkins/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pipeline {
7676
}
7777
```
7878

79-
### Step 3: Access Your Results
79+
### Step 2: Access Your Results
8080

8181
After the build completes:
8282
1. Go to the build page

0 commit comments

Comments
 (0)