Impossible to add a new env variable with the character `


The title is self explanatory, i’m unable to add a env variable with the character " ` " in it. This is our DB password, so being sensitive data, i’d rather not put them into a file that’ll be pushed on our repo ( either a .env or the config.yml file )

Any tricks to make it work ? i’ve tried to escape it, but it output the wrong password ( it keeps the \ ) and quote / double quote too ( ive asserted that the ` symbol was problematic since the variable adding works fine without it


I think the problem is that bash has trouble with the ` character.

I would suggest encoding and decoding base64, note that you still need to escape ` when encoding.

For example:

# notice how this does not echo
root@wp:~# echo "abc`"
> ^C

# escaping works 
root@wp:~# echo "abc\`"

# encode and add the result as the ENVVAR 
root@wp:~# echo "abc\`" | base64

# decode as a part of the build 
root@wp:~# echo "YWJjYAo=" | base64 --decode


That fix would totally work indeed. It’s just a bit weird to have to encode your env variable first hand. As I said, it’s a DB password so it shouldn’t change, but this might give some people a lot more of headaches if it would.



I’m having a bit of trouble to decoding it during the build, here’s the part of my code

      - run : DB_PASSWORD = $ENCODED_DB_PASSWORD | base64 --decode
      - run : echo $DB_PASSWORD

The $ENCODED_DB_PASSWORD is the original password in base64. The last command output " $DB_PASSWORD" and not the decoded version of $ENCODED_DB_PASSWORD. I lack bash skills but I’ve tried different thing ( putting it in the environment section, adding it to $BASH_ENV ) and it doesn’t seem to work. Any idea or leads?


Yeah, each command runs in a separate shell so the value of DB_PASSWORD will not persist. If you want to add it to the global environment you should do something like this:

Or you can run it all on a single line and it should work. i.e.



This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.