Skip to content
Snippets Groups Projects

CI: Add 'triggers' keyword to 'only' and 'except' lists to allow control over when triggers cause builds to run

Currently, the only and except keywords in .gitlab-ci.yml only accept ref names or the special branches and tags keywords. However, these are primarily useful when controlling how repository activity affects the creation of builds. In my case, instead of building on every commit, I'd like to use the following logic:

  • If the repository is tagged, do a build.
  • Any other normal commits should not cause a build.
  • If a build is triggered via the API, always create one for the specified ref.

From what I can tell, this isn't possible via the existing YAML syntax. In this MR, I introduce a new keyword triggers that goes along with branches and tags. I can implement the logic above using the following job configuration:

only:
  - tags
  - triggers

I updated the tests and documentation to reflect this and everything seems to pass.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading