Search code examples
gitlabgitlab-cigitlab-ci-runner

Escape char in Gitlab Secret Variables


I have a secret var :

enter image description here

But when I do - echo %MySecretVar%, runner displays foo only

How can i escape special chars like ! in Gitlab Secret Vars ?


Solution

  • I had the same problems with Gitlab, job running on windows, but I assume it will reproduce on Linux as well, because it seems Gitlab parsing issue or relay weird escaping.

    So I have set environment variable

    APPPOOL_PWD: 'blabla!foo$bar'
    

    and output of echo %APPPOOL_PWD% or echo $APPPOOL_PWD was 'blabla'

    The Gitlab seems to be was eating out the exclamation mark sign ! and dollar sign $. To avoid it as proposed in comment for exclamation mark I have used ^^ and for dollar sign I have used $$ as proposed in the Gitlab variables documentation.

    So following variable works well:

    APPPOOL_PWD: 'blabla^^!foo$$bar'

    and output of the echo command in this case would be 'blabla!foo$bar'.