Downstream pipelines have issues with predefined variables
Workaround
It is possible to stop global variables from reaching the downstream pipeline more information on our documentaiton https://docs.gitlab.com/ee/ci/pipelines/multi_project_pipelines.html#pass-cicd-variables-to-a-downstream-pipeline-by-using-the-variables-keyword .
More information about why this is happening on the comment below
Summary
I have two pipelines, one triggering the other, and they share a variable with the same key. The downstream pipeline seems to have this value deleted by the upstream pipeline
Steps to reproduce
Create two projects with those gitlab-ci configurations:
upstream-project
:
variables:
CACHE_FOLDER: '$CI_PROJECT_DIR/cache'
step1:
stage: .pre
script:
- echo 'Upstream CACHE_FOLDER'
- echo $CACHE_FOLDER
step2:
stage: .post
trigger: downstream-project
downstream-project
:
variables:
CACHE_FOLDER: '$CI_PROJECT_DIR/cache'
step1:
stage: .pre
script:
- echo 'Downstream CACHE_FOLDER'
- echo $CACHE_FOLDER
If I launch the second pipeline only I get
Downstream CACHE_FOLDER
/builds/downstream-project/cache
What is the current bug behavior?
The echos I get:
Upstream CACHE_FOLDER
/builds/upstream-project/cache
Downstream CACHE_FOLDER
/cache
What is the expected correct behavior?
The echos I expect:
Upstream CACHE_FOLDER
/builds/upstream-project/cache
Downstream CACHE_FOLDER
/builds/downstream-project/cache
I corrected it by doing
upstream-project
:
.variables: &global_variables
CACHE_FOLDER: '$CI_PROJECT_DIR/cache'
step1:
stage: .pre
variables: *global_variables
script:
- echo 'Upstream CACHE_FOLDER'
- echo $CACHE_FOLDER
step2:
stage: .post
trigger: downstream-project
Edited by Andrew Conrad