Cannot use variables with $ character directly in gitlab ci file
Summary
When you have a project variable that has a dollar sign in it, there is no way to save the variable such that the CI runner does not interpret the variable. Even if you surround the keys value with single quotes it still gets interpreted which is counter intuitive to how bash works.
Steps to reproduce
Create a project and add a variable with a $ sign ex KEY = MY_VAR, VAL = dollar$ign. Create a gitlab ci file like the one below to test it out `` stages:
print: stage: print script: - echo "$MY_ENV" ``
Expected behavior
If you surround the variables value with a single quote it should be protected from being re-interpreted
Actual behavior
The variable ignores the single quotes and does the interpretation anyway
Relevant logs and/or screenshots
OUTPUT FROM RUNNING VARIABLE INTERPOLATION ON RUNNER
$ MY_ENV=dollar$ign $ echo $MY_ENV dollar $ MY_ENV="dollar$ign" $ echo $MY_ENV dollar $ MY_ENV='dollar$ign' $ echo $MY_ENV dollar$ign
OUTPUT FROM GITLAB CI JOB
NOTE: Project variable in gitlab project
MY_ENV = 'dollar$ign'
Running with gitlab-ci-multi-runner 1.5.2 (76fdacd) Using Shell executor... Running on ... Fetching changes... HEAD is now at b895004 switching to double quotes From b895004..2b2a168 master -> origin/master Checking out 2b2a1688 as master... $ echo "$MY_ENV" 'dollar' Build succeeded
Possible fixes
Gitlab CI variables should respect if they are surrounded in single quotes