Encrypted variable in Travis as the value of a secure key

I’ve tried a variety of solutions and I can’t find something that works. My problem is that I want to be able to put a deployment key (what GitHub calls a personal authorization token or personal OAuth token ) into an encrypted variable, in basically a bash script, any way to work around this?

deploy:
    api_key:
        secure: $DEPLOYMENT_KEY`

could I simply add my own Travis variable and not touch the code at all?

thanks!

You cannot write:

deploy:
  api_key:
    secure: $DEPLOYMENT_KEY

Decryption happens in an early stage of the Travis build process; the encrypted value will be passed on to the app which compiles the bash script to build. Since the part that is responsible for decrypting secrets doesn’t know anything about $DEPLOYMENT_KEY, this configuration will ultimately fail.

To achieve what you are after, you can use the repository settings to define secrets.

See Environment Variables - Travis CI.

1 Like