Dependency Scanning only on master

I’m running GitLab CI on gitlab.com, and have been using the dependency scanner by adding this to my .gitlab-ci.yml file:

include:
  template: Dependency-Scanning.gitlab-ci.yml

This works great! Except that it’s running on every branch, and while this provides really good information, it takes about 5mins to run, which is too much for a feature branch.

I’ve read the documentation but haven’t found a way to turn off selectively.

Is this possible?

What about


include:
  template: Dependency-Scanning.gitlab-ci.yml

dependency_scanning_job_name:
  rules:
    - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
      when: always
  • Read more about rules here

If my answer solves your problem, please mark as the solution, else provide more information so we can figure this out.

1 Like

I’m not using rules in my .gitlab-ci.yml file yet, but this worked:

dependency_scanning:
  only:
    - master

I didn’t know that I could merge configuration into a template! Thank you :slight_smile:

1 Like

I’m glad it worked!

There’s a reason I used “rules” (link)

1 Like