Skip to content

Commit 8694aba

Browse files
authored
[CRAVEX] Add support for GitLab CI/CD (#29)
Signed-off-by: tdruez <[email protected]>
1 parent 805ea00 commit 8694aba

File tree

4 files changed

+141
-3
lines changed

4 files changed

+141
-3
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
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+
## Supported Platforms
7+
8+
| Platform | Documentation |
9+
|----------|---------------|
10+
| **GitHub Actions** | See [GitHub Actions documentation](https://github.com/aboutcode-org/scancode-action/blob/main/README.md) |
11+
| **GitLab CI/CD** | See [GitLab documentation](https://github.com/aboutcode-org/scancode-action/blob/main/gitlab/README.md) |
12+
| **Jenkins** | See [Jenkins documentation](https://github.com/aboutcode-org/scancode-action/blob/main/jenkins/README.md) |
13+
| **Azure Pipelines** | See [Azure Pipelines documentation](https://github.com/aboutcode-org/scancode-action/blob/main/azure-pipelines/README.md) |
814

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