Lost variable values in transitive multi-project pipelines
Summary
GitLab CI allows it to pass variables from upstream to downstream pipelines in multi-project setups:
This feature works nicely as long as there are only two pipelines involved (no indirection). However, as soon as the second pipeline in turn triggers a third one (transitivity), variable values are lost.
Steps to reproduce
- Set up a simple project ("downstream") whose pipeline just prints out a variable.
- Create another project ("downstream-upstream") that triggers the first one.
- Add a third project ("upstream") that triggers the pipeline of the second one and defines the variable to be passed and printed out.
Pipeline trigger scheme: upstream -> downstream-upstream -> downstream
Example Project
- https://gitlab.com/multi-project-pipelines/downstream/-/blob/main/.gitlab-ci.yml
- https://gitlab.com/multi-project-pipelines/downstream-upstream/-/blob/main/.gitlab-ci.yml
- https://gitlab.com/multi-project-pipelines/upstream/-/blob/main/.gitlab-ci.yml
What is the current bug behavior?
Variable values are lost. In the provided example the downstream pipeline prints out "FOO=FOO" (local value):
https://gitlab.com/multi-project-pipelines/downstream/-/jobs/2463098299
What is the expected correct behavior?
Variable values are kept. In the provided example the downstream pipeline prints out "FOO=BAR" as previously defined in the initial upstream pipeline.
Relevant logs and/or screenshots
See the links provided in the sections before.
Output of checks
This bug happens on GitLab.com (but is reproducible on a local installation as well).
Results of GitLab environment info
GitLab.com as of today.
Results of GitLab application Check
GitLab.com as of today.
Possible fixes
Workaround:
Let variables reference themselves in the second pipeline:
variables:
FOO: $FOO