Reputation: 1705
Travis CI's user documentation has a section on how to escape secure environment variables. It seems not to work for the '$' symbol. Is there anything special that needs done for the '$' symbol?
I setup this example. In .travis.yml:
travis encrypt "FAKE_PASSWORD=H3llo\\#Worl\\$d" -a
In my script I echo the variable and get:
fake password is H3llo#Worl
It appears that $d
is being replaced with nothing. How can I fix this?
Upvotes: 1
Views: 2121
Reputation: 1705
The problem is when running travis encrypt
the $
symbol needs to be escaped for the command as well as when the variable is used. With two backslashes \\
it only creates one backslash in the variable and $d
is still expanded by bash. Using three backslashes fixes the issue.
travis encrypt "FAKE_PASSWORD=H3llo\\#Worl\\\$d" -a
\\
creates a single backslash and \$
creates a $ symbol that is not expanded by bash. When travis runs the bash command to create that variable looks like
FAKE_PASSWORD=H3llo\\#World\$d
This is what bash expects when using a $
in a variable.
Upvotes: 4