Global variables must be explicitly forwarded to nested child pipeline, which overrides job variables - update documentation.
Related to investigation results: #404772 (closed)
Summary
The documentation states that global variables are passed to child pipelines implicitly:
- https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html#pass-yaml-defined-cicd-variables states that by defining global variables in the parent CI config, they are automatically passed to a child pipeline, where they become 'trigger variables': "all jobs in a pipeline, including trigger jobs, inherit global variables"
- https://docs.gitlab.com/ee/ci/variables/index.html#cicd-variable-precedence lists 'trigger variables' at the very top of the variable precedence chain - above even global variables.
- https://docs.gitlab.com/ee/ci/triggers/index.html#pass-cicd-variables-in-the-api-call implies that 'trigger variables' have the highest priority of all variables and will always be passed to everything: "These variables have the highest precedence, and override all variables with the same name."
Therefore, when passing variables from a parent to a child pipeline, I expect those variables to also be passed to children of that child pipeline.
However, when starting a nested child pipeline, global variables defined in the parent are not passed to it.
Considering the workaround, mentioned #404772 (closed):
There is a workaround: unless the nested child pipeline is triggered with
forward: pipeline_variables: true
- which documentation >states is reserved for "manual pipeline variables and scheduled pipeline variables" - not global or trigger variables. >(https://docs.gitlab.com/ee/ci/yaml/index.html#triggerforward)
is the only way to forward pipeline variables to the downstream pipeline.
- Update documentation around variable boundaries in case of upstream, downstream pipelines and the way we pass it to the child/downstream pipeline
- Improve documentation around the precedence of YAML and triggered variables.
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.