Using CI-variables for tags
Problem Statement
It should be possible to use variables in tags in a pipeline definition (see GitLab documentation on tags). This works well, if the variable is a pre-set CI variable. However, when changing this variable to the value of another variable, no variable substitution is performed.
Proof of Concept
A proof of concept can be found in this public repository:
In the example, there is CI variable called MY_CI_TAG
.
In the pipeline definition, if this variable is set, its value is used to set another variable JOB_TAG
to its value.
If it is not set, the variable JOB_TAG
will have its default value default-tag
.
In the example pipeline of this repository, there are two jobs:
-
test
: always runs and outputs the value ofMY_CI_TAG
andJOB_TAG
. -
test-tagged
: is run with tagJOB_TAG
and outputs the value ofJOB_TAG
.
After the pipeline ran, one can see that the Job tags of test-tagged
is set to $MY_CI_TAG
, although the value of MY_CI_TAG
is set to my-tag
, which can be seen in the output of the job test
.
Further Reading
I found a report of a similar problem in the GitLab forum, but in this thread, the discussion got stuck.
This problem is really severe since it restricts the creation of dynamic tags for runners and is, thus, not in line with the GitLab documentation.