Hi, I have got 3 projects, which are chain triggered. I want to pass variable from first project to third and facing strange behavior.
So, in Project A I m creating variable VARIABLE_1 with value hello_world and passing it to Project B
Project A .gitlab-ci.yaml:
stages:
- trigger_downstream
variables:
VARIABLE_1:
value: "hello_world"
".trigger_env":
stage: trigger_downstream
inherit:
variables:
- VARIABLE_1
trigger_downstream:
extends: ".trigger_env"
trigger:
project: 'Project B'
branch: 'main'
In Project B, I ve echod $VARIABLE_1 and got hello_world output. This means our variable is in the env. So i am passing it to the Project C.
Project B .gitlab-ci.yaml:
stages:
- printenv
- trigger_downstream
printenv:
stage: printenv
script:
- echo "VARIABLE_1 = $VARIABLE_1"
".trigger_env":
stage: trigger_downstream
inherit:
variables:
- VARIABLE_1
trigger_downstream:
extends: ".trigger_env"
trigger:
project: 'Project C'
branch: 'main'
In Project C , the output of echo is:
VARIABLE_1 =
There is no VARIABLE_1 in the env.
Project C .gitlab-ci.yaml:
stages:
- printenv
printenv:
stage: printenv
script:
- echo "VARIABLE_1 = $VARIABLE_1"
So i ve managed to workaround this with creating another variable in Project B:
variables:
VARIABLE_2:
value: "$VARIABLE_1"
And then passing it to Project C:
".trigger_env":
stage: trigger_downstream
inherit:
variables:
- VARIABLE_1
- VARIABLE_2
In this case we save our VARIABLE_1 value, so we still can acess its value in Project C.
But this is a bad solution in case you ve got a lot of variables in your CI, which you want to pass between pipelines. So, i ve got 2 questions:
- Is this behavior intentional or am i missing something ?
- Did anyone faced this problem, if so did you managed to find better workarounds ?