Group variables are not expanded when referenced in "VARIABLES" parameter from stage in .gitlab-ci.yml file
Hi everyone,
First of all I think Gitlab is a great tool and that you guys are doing a great job !
Secondely I searched for similar issues but I couldn't find anything closely related to what I am reporting today. Still I hope I'm not posting a duplicate right now and I apologize if it is the case. I also read the documentation regarding the variable expansion mechanism and did not find anything explaining why this use case doesn't work.
Lastly if it is an actual bug I'd be happy if anyone can submit a workaround for this use case, as my team really needs this level of indirection when designing CI/CD workflows.
Thank you for your time :)
Summary
Group variables are not correctly expanded when referenced in the VARIABLES:
parameter from a stage in .gitlab-ci.yml file, through another variable reference in project variables.
Steps to reproduce
- Create a new group,
- Add a variable in the CI/CD section of this group (Example : name = GROUP_VAR, value = val),
- Create a new project in this group,
- Add a variable in the CI/CD section of this project, referencing the group variable (Example : name: PROJECT_VAR, value: $GROUP_VAR),
- Add a .gitlab-ci.yml file in this project,
- Add a stage in .gitlab-ci.yml file, with a VARIABLE parameter in it, referencing the project variable (Example : name: FILE_VAR, value: $PROJECT_VAR),
- Add a script to the said stage to display the content of the variable as expanded at runtime (Example :
echo $FILE_VAR
)
Example Project
What is the current bug behavior?
The value displayed is the non-expanded name of the variable declared in the group variables, $GROUP_VAR
What is the expected correct behavior?
I would expect the actual value of the group variable to be displayed instead (here : val
). Using ${ } or enclosing the variable reference within quotes or double quotes didn't make it work either.
Relevant logs and/or screenshots
Job logs :
Running with gitlab-runner 12.7.1 (003fe500)
on docker-auto-scale 0277ea0f
Using Docker executor with image ruby:2.5 ...
00:16
Pulling docker image ruby:2.5 ...
Using docker image sha256:2e5f50365ef3ac3798131d71636bde8b6438db6352a55e854b015532eddc39dd for ruby:2.5 ...
Running on runner-0277ea0f-project-16608719-concurrent-0 via runner-0277ea0f-srm-1580392449-f3969930...
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/rsauvagetesting/test-project/.git/
Created fresh repository.
From https://gitlab.com/rsauvagetesting/test-project
* [new ref] refs/pipelines/113635831 -> refs/pipelines/113635831
* [new branch] master -> origin/master
Checking out a15b017f as master...
Skipping Git submodules setup
$ echo $FILE_VAR
00:02
$GROUP_VAR
Job succeeded
Output of checks
This bug happens on GitLab.com.