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:

https://docs.gitlab.com/ee/ci/pipelines/multi_project_pipelines.html#pass-cicd-variables-to-a-downstream-pipeline-by-using-the-variables-keyword

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

  1. Set up a simple project ("downstream") whose pipeline just prints out a variable.
  2. Create another project ("downstream-upstream") that triggers the first one.
  3. 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

  1. https://gitlab.com/multi-project-pipelines/downstream/-/blob/main/.gitlab-ci.yml
  2. https://gitlab.com/multi-project-pipelines/downstream-upstream/-/blob/main/.gitlab-ci.yml
  3. 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
Edited by Daniel Krämer