Parent YAML variables passed to child are not available when evaluating child pipeline's job's rules
Summary
Similar to #352828 (closed), which specifically targets dotenv variable inheritance between parent and child pipelines.
When a YAML variable is passed to a child pipeline as per our docs, it seems the variable is available in the job's build environment, but not available at the time the job's rules
are evaluated.
Steps to reproduce
- Create a project with the following CI/CD YAML:
variables:
BRANCH_NAME: $CI_COMMIT_BRANCH
trigger_job:
variables:
BRANCH_NAME: $BRANCH_NAME
trigger:
include:
- project: "gitlab-gold/tmike/zd398556/downstream_variable_rules/include"
ref: main
file:
- '/.gitlab-ci.yml'
strategy: depend
- Create a project with the following CI/CD YAML (contains the child pipeline):
do_not_run_if_stage:
rules:
- if: $BRANCH_NAME == "stage"
when: never
- when: on_success
script:
- echo $BRANCH_NAME
- if [[ "$BRANCH_NAME" == "stage" ]]; then echo true; else echo false; fi
- In the parent project, create a branch called
stage
Example Project
https://gitlab.com/gitlab-gold/tmike/zd398556/downstream_variable_rules/parent/-/pipelines/844096549
What is the current bug behavior?
Child pipeline is triggered with do_not_run_if_stage
job, as $BRANCH_NAME
equals stage
What is the expected correct behavior?
Child pipeline is not triggered with do_not_run_if_stage
job , as $BRANCH_NAME
equals stage
Relevant logs and/or screenshots
Output of checks
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)