Global variables redefined by a parent pipeline trigger job are not forwarded to child pipelines
Summary
When using variables in a trigger job in a parent pipeline to forward variables to a child pipeline, variables defined at the job level extrapolating from global variables are not received by the child pipeline.
Steps to reproduce
Define a parent pipeline in a project test-parent-project with a trigger job and variables as follows:
variables:
PROJECT_NAME: $CI_PROJECT_NAME #Global variable
trigger_job:
stage: build
variables:
PARENT_PROJECT_NAME_INTERPOLATED: $PROJECT_NAME #Job-level variable being set to the same value as the global variable
PARENT_PROJECT_NAME: $CI_PROJECT_NAME #Job-level variable being set to pre-defined variable, thus, not referencing global variable
trigger:
project: test-group/test-child-project
strategy: depend
At this point all the three variables should be set to the same value:
PROJECT_NAME: 'test-parent-project'
PARENT_PROJECT_NAME_INTERPOLATED: 'test-parent-project'
PARENT_PROJECT_NAME: 'test-parent-project'
As per the docs, both the global variables and the variables defined in the trigger job will be forwarded to the child pipeline.
In the child project test-child-project, define the following job to get the values of the variables:
build:
script:
- echo $PROJECT_NAME
- echo $PARENT_PROJECT_NAME
- echo $PARENT_PROJECT_NAME_INTERPOLATED
The result of this job is:
$ echo $PROJECT_NAME
test-parent-project
$ echo $PARENT_PROJECT_NAME
test-parent-project
$ echo $PARENT_PROJECT_NAME_INTERPOLATED
test-child-project
The variable $PARENT_PROJECT_NAME_INTERPOLATED references the child-project name instead of the original parent-project name.
What is the current bug behavior?
The variable re-defined at the trigger job level, referencing (interpolating) a global variable is not properly forwarded to the child pipeline.
What is the expected correct behavior?
All variables are properly forwarded to the child pipeline.
Output of checks
This bug happens on GitLab.com