Skip to content

Variable can be used on `include.ref` in `.gitlab-ci.yml`

Problem to solve

As a dev ops engineer, I want to be able to use a variable in include.ref in my .gitlab-ci.yml, so I can update a CI variable in the group and I don't have to update the .gitlab-ci.yml of every projects

Intended users

Developer, DevOps engineer.

User experience goal

As a dev ops engineer, I would like to maintain multiple projects pipelines with a template. The problem comes when I want to update the template. I would like pipelines to reference the template from a tag:

include:
  project: 'my-group/ci-pipelines'
  ref: v1
  file: 'templates/main.yml'

Then, if I create a new tag to fix a bug in the pipeline, I have to go through every single projects to update that ref to v2 which is long and cumbersome.

Proposal

If the .gitlab-ci.yml was allowing to reference a variable:

include:
  project: 'my-group/ci-pipelines'
  ref: $PIPELINE_TEMPLATE_REF
  file: 'templates/main.yml'

Then I would only have to update this variable in the group CI variables.

References

https://docs.gitlab.com/ee/development/cicd/#ci-architecture-overview

Edited by Tan Le