Problem to solve
I am experiencing an issue where GitLab is running multiple jobs for Maven dependency scanning (gemnasium-maven-dependency_scanning, gemnasium-maven-dependency-scanning-2, and gemnasium-maven-dependency-scanning-3).
Expected Behavior:
- The dependency scanning jobs should run once per pipeline execution as defined in
.gitlab-ci.yml. - The script
mvn-create-settings.bashshould execute before the analyzer run without issues.
Actual Behavior:
- Multiple instances of the Maven dependency scanning job (
-2,-3, etc.) appear unexpectedly. - The
gemnasium-maven-dependency-scanning-2job fails, whilegemnasium-maven-dependency_scanningexecutes successfully. - The error log is attached in the file gemnasium-maven-dependency-scanning-2.
Additional Context:
- The script
mvn-create-settings.bashis used to generate ansettings.xmlfile with secrets from GitLab variables for accessing the local Artifactory. - Scanning policies are enabled for all branches, triggering scans:
- On every merge request
- On merge to
main - On a scheduled Sunday scan
Question:
- Why are multiple jobs being created (
-2,-3, etc.)? - How can I ensure only one job executes?
- What is the best practice for providing custom setups for handling policy-based security scanning tools?
Steps to reproduce
-
Enable dependency scanning policies on all branches.
-
Add the following
.gitlab-ci.ymlconfiguration or one that creates local settings dependent to run the job:gemnasium-dependency_scanning: before_script: - source <(curl -s https://gitlab-script.utv.atlas.vegvesen.no/download/mvn-create-settings.bash) gemnasium-maven-dependency-scanning-2: before_script: - source <(curl -s https://gitlab-script.utv.atlas.vegvesen.no/download/mvn-create-settings.bash) gemnasium-maven-dependency_scanning: before_script: - source <(curl -s https://gitlab-script.utv.atlas.vegvesen.no/download/mvn-create-settings.bash) -
Run a pipeline and observe multiple executions of the Maven dependency scanning job.
-
Check the screensjot for failures in
Configuration
- GitLab security feature: Dependency Scanning
- Custom Script Usage:
mvn-create-settings.bash - Artifacts Repository: Internal Artifactory for Maven dependencies
Versions
- Self-managed
-
GitLab.com SaaS - Dedicated
- Self-hosted Runners
GitLab Version: 17.5.4-ee
GitLab Runner Version: 17.5.4
Helpful resources
- Check the FAQ for helpful documentation, issues/bugs/feature proposals, and troubleshooting tips.
- Before opening a new topic, make sure to search for keywords in the forum search
- Check the GitLab and GitLab Runner projects for existing issues. If you encounter a bug, please create a bug report issue.
- Review existing troubleshooting docs.
Thanks for taking the time to be thorough in your request, it really helps! ![]()

