Update CI/CD templates to stop using hardcoded `master`
Problem
devopscreate is going to change the default branch name from master
to main
in 14.0. This subsequently breaks the CI/CD templates that has a hardcoded only: master
.
Example of potential impacts:
- User creates a new project and picks a CI/CD template from UI, however, pipelines won't be triggered. In this case, the user has to fix the .gitlab-ci.yml by themself.
- User creates a new project and
include
a template, however, the included jobs won't be triggered. In this case, the user has to override theonly
orrules
in the template.
We should investigate which the templates should be refactored in 14.0.
Proposal
As part of the move away from master
to main
default branches (see linked Epic), we need to update our CI/CD templates to match.
This can be done immediately for:
- Templates that are for copy/paste examples.
-
latest
templates: https://docs.gitlab.com/ee/development/cicd/templates.html#latest-version
This should be delayed to 14.0 for breaking changes:
- Templates that are used with
include
-
stable
templates: https://docs.gitlab.com/ee/development/cicd/templates.html#stable-version
only
(but not except):
Templates that use Before:
only:
- master
After:
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
except
(and possibly only
)
Templates that use These need to be handled differently. If you do a simple replacement like above, but with !=
, the job will also run in MR pipelines. When #300146 is complete, we can probably change these to simple rules. For now, as an MVC, perhaps we should go with:
Before:
except:
- master
only
- master
After:
except:
variables:
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
only:
variables:
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
Template list
From a quick search by Shinya, we need to review/update all these templates, as a start:
14.0 breaking changes
-
/gitlab/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
-> Code comment links only, update with 14.0 -
/gitlab/lib/gitlab/ci/templates/Docker.gitlab-ci.yml
-> Likely breaking change forinclude
style template. Do in 14.0? -
/gitlab/lib/gitlab/ci/templates/Managed-Cluster-Applications.gitlab-ci.yml
-> Likely breaking change forinclude
style template. Do in 14.0? -
/gitlab/lib/gitlab/ci/templates/Terraform.latest.gitlab-ci.yml
-> Just a link tohttps://gitlab.com/gitlab-org/gitlab/blob/master/
, update in 14.0
Another Milestone (if time needed)
-
/gitlab/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Jobs/Deploy.latest.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Julia.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Maven.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Mono.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/OpenShift.gitlab-ci.yml
-> Copy-paste example style. Likely safe to do now? -
/gitlab/lib/gitlab/ci/templates/Packer.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Brunch.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Doxygen.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Gatsby.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Harp.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Hexo.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/HTML.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Hugo.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Hyde.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Jekyll.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Jigsaw.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Lektor.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Metalsmith.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Middleman.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Nanoc.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/Octopress.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Pages/SwaggerUI.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Python.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml
-> Code comments link to master in a different project, does not need any changes. -
/gitlab/lib/gitlab/ci/templates/Swift.gitlab-ci.yml
-
/gitlab/lib/gitlab/ci/templates/Terraform.gitlab-ci.yml
-> Copy-paste example style. Likely safe to do now? -
/gitlab/lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml
->latest
type, OK to do now?