Backend: Variable expansion of inherited variables in child pipeline
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
Variables created in a parent, but inherited by a child pipeline are not properly expanded.
Steps to reproduce
- Create a group level CI/CD variable named
TARGET_ENVwith the value set to "DEV" - Create an Environment called "DEV"
- Add .gitlab-ci.yml:
stages:
- output
- trigger_child
variables:
PARENT_VARIABLE: "test-$TARGET_ENV-variable"
Output Job:
stage: output
environment: 'DEV'
script:
- echo "$PARENT_VARIABLE"
- ls
Child Trigger Job:
stage: trigger_child
trigger:
include: 'child-pipeline.yml'
- Create child-pipeline.yml
stages:
- child-job
variables:
CHILD_VARIABLE_TEST: "Test-$PARENT_VARIABLE"
DIRECT_VARIABLE_TEST: "Direct-$TARGET_ENV-variable"
LOCAL_VARIABLE_TEST: "test"
Child Job:
stage: child-job
environment: 'DEV'
script:
- echo "$CHILD_VARIABLE_TEST"
- echo "$DIRECT_VARIABLE_TEST"
- echo "$TARGET_ENV"
- echo "$LOCAL_VARIABLE_TEST"
- Run pipeline, observe output from the child pipeline, noting that
$CHILD_VARIABLE_TESTis does not contain the value of$PARENT_VARIABLE
[...]
$ echo "$CHILD_VARIABLE_TEST"
Test-test--variable
$ echo "$DIRECT_VARIABLE_TEST"
Direct-DEV-variable
$ echo "$TARGET_ENV"
DEV
$ echo "$LOCAL_VARIABLE_TEST"
test
[...]
Example Project
https://gitlab.com/tmarsh1/var-set-in-parent-not-expanded-in-child-pipeline
What is the current bug behavior?
$CHILD_VARIABLE_TEST returns Test-test--variable
What is the expected correct behavior?
$CHILD_VARIABLE_TEST returns Test-test-DEV-variable
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: \\\`sudo gitlab-rake gitlab:env:info\\\`) (For installations from source run and paste the output of: \\\`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production\\\`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of: \`sudo gitlab-rake gitlab:check SANITIZE=true\`) (For installations from source run and paste the output of: \`sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true\`) (we will only investigate if the tests are passing)
Possible fixes
Edited by 🤖 GitLab Bot 🤖