Can't Override Variables While Triggering Child Pipeline
Disclaimer
Haven't found this issue among the existing or closed ones, but I suspect that someone has already come across it at some point, so my apologies for a potential duplicate.
Summary
Environment variables defined within one Gitlab project seem to be impossible to override while executing as part of a child pipeline.
Gitlab version: 13.0.6-ee
Context
In our case, we have 2 projects, for simplicity, let's call those projects: Parent (P) and Child (C).
Upon integration of the changes made in the project P, we need to ensure that project C is intact. To get the best use of the features provided by Gitlab, we've been trying to set up a parent-child pipeline that would trigger the execution of some of the jobs from the project C as part of the integration process for the project P.
To establish such a process, we have defined our CI configuration as the following:
In the project P, we would put the following in its gitlab-ci.yml file:
parent-pipeline:
stage: init
rules:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
when: always
- when: never
variables:
TRIGGER_CHILD: "true"
trigger:
project: child
branch: master
strategy: depend
The project C has its setup as the following:
gitlab-ci.yml
include:
- local: '/.gitlab-configuration/workflow.yml'
- local: '/.gitlab-configuration/rulebook.yml'
- local: '/.gitlab-configuration/base.yml'
- local: '/.gitlab-configuration/shared.yml'
- local: '/.gitlab-configuration/child-pipeline.yml'
variable SCHEME is defined inside '/.gitlab-configuration/workflow.yml':
variables:
SCHEME: "Base"
And overridden in '.gitlab-configuration/infrastructure-test.yml', which is included in .gitlab-configuration/child-pipeline.yml as:
parent_downstream:
extends:
- .rules_parent_downstream
trigger:
include:
- local: '/.gitlab-configuration/infrastructure-test.yml'
strategy: depend
the contents of '.gitlab-configuration/infrastructure-test.yml':
include:
- local: '/.gitlab-configuration/base.yml'
- local: '/.gitlab-configuration/shared.yml'
scheme_override:
extends:
- .some_base_job_template
variables:
UNIQUE_VAR: "TEST"
SCHEME: "Overridden"
Steps to reproduce
A new pre-merge pipeline is being created upon every new commit to the branch in the project P.
What is the current bug behavior?
The value of the variable SCHEME remains the same (Base) upon execution of job scheme_override as part of the downstream of the child pipeline for the project P.
At the same time, the value of the variable UNIQUE_VAR becomes TEST, as expected.
What is the expected correct behavior?
The value of the variable SCHEME gets overridden with the value set in the job scheme_override (Overridden). The value of the variable UNIQUE_VAR continues to be set as expected.
Output of checks
This bug happens on Gitlab Enterprise Edition. Version 13.0.6
~bug Enterprise Edition