Reputation: 555
How to add .gtilbic.yml to project with many branches which has to be triggered only on commit to master branch.Do i have to edit yml with rule only master branch in every git branch?
Upvotes: 0
Views: 1129
Reputation: 40861
Just add your .gitlab-ci.yml
file to the default (master) branch. The file can contain a workflow:rules:
that makes sure that pipelines are only triggered for commits to the master branch.
workflow:
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
my_job:
script:
- make test # or whatever
Typically, you need this file present in all branches where you want pipelines to run. However, because you only want to run pipelines on the default branch, it's not super important that your branches contain the yaml.
If you did want to add CI to run on your other branches you could either merge/cherry-pick the change from the default branch into all your branches.
Alternatively, you can use the projects CI/CD settings to specify a custom configuration file that lives in another project. When you apply this setting, it will apply the configuration from the remote project to be triggered for all branches (or other pipeline events).
Upvotes: 1