I have the situation where we have .gitlab-ci.yml in master which is different in brach 'development' the problem is we have a lot of repos with a lot of branches.
I want to make a change to .gitlab-ci.yml but I want to be sure all branches are using the same .gitlab-ci.yml. I know gitlab by design leave you to have different CI CD for your branches because your pipelines could be different.
One way to do it is to get all repos with all branches and just copy the same .gitlab-ci.yml to all repos and branches.
Do you know some kind of better way to do it ?
You can use the include keyword. It allows you to include a file from a remote URL or a special project containing your pipelines. You can, for example, create lots of "hidden" templates prefixing them with . and then including them into your pipeline using the extends keyword as needed. This also allows you to configure your pipeline template using variables.
Note: The include is executed when the pipeline is created. It is therefore not possible to fix a pipeline after it has been created by fixing the included file.
Old answer:
If you use the enterprise edition you can use the include keyword.
If you are using the community edition, the best option I can think of is having a check-yaml job. It basically runns git diff master -- .gitlab-ci.yml[1]. If the .gitlab.yml on the branch and master differ, the job will fail, forcing you to update your branch. While this will not keep your pipelines in sync automatically, a diversion will not go unnoticed.
[1]: You might need to run git fetch master, depending on your git strategy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With