workflow:rules CI templates to replace repeated calls to `if: '$CI_MERGE_REQUEST_ID'`
When using gitlab CI rules both branch/tags and merge requests pipelines are triggered. This is an unwanted behavior in our case as we do not use MR pipelines. To block this, we added for almost all jobs the call to:
- if: '$CI_MERGE_REQUEST_ID'
when: never
To remove this repetition and cleanup CI code we can use workflow rules instead, which allow to define a global series of rules that apply to the entire CI pipeline. Starting from gitlab 13.1, templates for rules are available and we can finally remove specific calls from each job and include the Branch-Pipelines template, which is suitable for our case:
include:
- template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'