i’m tying to use this parser to get the reports from GitLab SAST and convert them in HTML.
Problem: the artifacts are only available at pipeline level (not at job level), so this means that my stage can not consume the JSON file, since it is not able to find it.
I wanted to ask if there is any workaround for this taking in account that:
- I don’t want to define or hard-code anything for the SAST template
- I dockerized the parser, that i’m using as a Docker image in a GitLab template
Down the .gitlab-ci file and the template that i’m using:
.gitlab-ci
<code>include:
- template: Jobs/SAST.gitlab-ci.yml
- project: "my-templates"
ref: main
file:
- "sast-parser.yml"
stages:
- test
- pre-job-stage
- sast-parser
pre-job:
stage: pre-job-stage
extends: .collect-artifacts
sast-parser:
stage: sast-parser
extends: .sast-parser
</code>
<code>include:
- template: Jobs/SAST.gitlab-ci.yml
- project: "my-templates"
ref: main
file:
- "sast-parser.yml"
stages:
- test
- pre-job-stage
- sast-parser
pre-job:
stage: pre-job-stage
extends: .collect-artifacts
sast-parser:
stage: sast-parser
extends: .sast-parser
</code>
include:
- template: Jobs/SAST.gitlab-ci.yml
- project: "my-templates"
ref: main
file:
- "sast-parser.yml"
stages:
- test
- pre-job-stage
- sast-parser
pre-job:
stage: pre-job-stage
extends: .collect-artifacts
sast-parser:
stage: sast-parser
extends: .sast-parser
sast-parser.yml
<code>.collect-artifacts:
image: sast-dashboard
script:
- mkdir artifacts
- mv *gl-sast-report.json artifacts/
artifacts:
paths:
- artifacts/*.json
.sast-parser:
image: sast-dashboard
script:
- sast-parser
- for file in $(ls artifacts/*gl-sast-report.json); do if [ -f "$file" ]; then sast-parser "$file" > "${file%.json}.html"; else echo "$file does not exist"; exit 1; fi; done
artifacts:
paths:
- "*.html"
</code>
<code>.collect-artifacts:
image: sast-dashboard
script:
- mkdir artifacts
- mv *gl-sast-report.json artifacts/
artifacts:
paths:
- artifacts/*.json
.sast-parser:
image: sast-dashboard
script:
- sast-parser
- for file in $(ls artifacts/*gl-sast-report.json); do if [ -f "$file" ]; then sast-parser "$file" > "${file%.json}.html"; else echo "$file does not exist"; exit 1; fi; done
artifacts:
paths:
- "*.html"
</code>
.collect-artifacts:
image: sast-dashboard
script:
- mkdir artifacts
- mv *gl-sast-report.json artifacts/
artifacts:
paths:
- artifacts/*.json
.sast-parser:
image: sast-dashboard
script:
- sast-parser
- for file in $(ls artifacts/*gl-sast-report.json); do if [ -f "$file" ]; then sast-parser "$file" > "${file%.json}.html"; else echo "$file does not exist"; exit 1; fi; done
artifacts:
paths:
- "*.html"