Variable Depth Limited to 2.
Summary
While having variables use other variables, values get used only until a depth of 2. The third depth just uses the variable name.
Steps to reproduce
Here is a sample .gitlab-ci.yml
file that shows the issue:
image: docker:git
variables:
VAR_A: A
VAR_B: B_$VAR_A
VAR_C: C_$VAR_B
VAR_D: D_$VAR_C
review:
variables:
LOCAL_A: A
LOCAL_B: B_$LOCAL_A
LOCAL_C: C_$LOCAL_B
LOCAL_D: D_$LOCAL_C
MIXED_A: M_$VAR_A
MIXED_B: M_$VAR_B
MIXED_C: M_$VAR_C
MIXED_D: M_$VAR_D
script:
- echo $VAR_A
- echo $VAR_B
- echo $VAR_C
- echo $VAR_D
- echo $LOCAL_A
- echo $LOCAL_B
- echo $LOCAL_C
- echo $LOCAL_D
- echo $MIXED_A
- echo $MIXED_B
- echo $MIXED_C
- echo $MIXED_D
What is the current bug behavior?
Job Output:
$ echo $VAR_A
A
$ echo $VAR_B
B_A
$ echo $VAR_C
C_B_$VAR_A
$ echo $VAR_D
D_C_$VAR_B
$ echo $LOCAL_A
A
$ echo $LOCAL_B
B_A
$ echo $LOCAL_C
C_B_$LOCAL_A
$ echo $LOCAL_D
D_C_$LOCAL_B
$ echo $MIXED_A
M_A
$ echo $MIXED_B
M_B_$VAR_A
$ echo $MIXED_C
M_C_$VAR_B
$ echo $MIXED_D
M_D_$VAR_C
Variables do not fully flatten their values. Variable values are not consistent, depending on usage depth (see VAR_B
's usage).
What is the expected correct behavior?
Variables should fully expand. Variables' values should at least be consistent -- regardless of usage context.
Example Project
I've made this public project to demonstrate the issue: https://gitlab.com/CauhxMilloy/ci-variable-depth-bug
Here is the ci run: https://gitlab.com/CauhxMilloy/ci-variable-depth-bug/-/jobs/53313550
Other Comments
I'm new to Gitlab and Gitlab CIs. I don't know if this is just an error or oversight on my part. I looked through CI variable documentation and Issues related to variables. I'm not sure if I maybe overlooked some config parameter that controls expansion depth (that is defaulted to 2)..? I couldn't find anything, so I'm filing this issue... sorry if I overlooked something.