The travis encryption docs mention that I have to bash-escape my password before encrypting it:
Note on escaping certain symbols
When you use travis encrypt to encrypt sensitive data, it is important to note that it will be processed as a bash statement. This means that secret you are encrypting should not cause errors when bash parses it. Having incomplete data will cause bash to dump the error statement to the log, which contains portions of your sensitive data.
Thus, you need to escape special characters such as braces, parentheses, backslashes, and pipe symbols. For example, when you want to assign the string
6&a(5!1Ab\
toFOO
, you need to execute:
travis encrypt "FOO=6\\&a\\(5\\!1Ab\\\\"
The answer for bash seems to revolve around printf "%q"
, but it's still too complicated to figure out how to wire printf
with the travis
cli.
What's the bash one-liner for having travis encrypt
do what it's supposed to do?
I mean, I want to paste my variable name and its value and be sure that it will be encrypted properly, without having to worry about bash escaping. We can stay with the example above, assuming I want to assign the string 6&a(5!1Ab\
to the variable FOO
.
And while we're at it, what would be the corresponding one-liner for travis env set
? That would help those fighting with the data too large
error.