vossad01
vossad01

Reputation: 11948

How do I encrypt a build step?

I need a secret token to be part of a command executed by Travis CI, but am in a public repository. I found that I can encrypt parts of .travis.yml to keep secrets safe. However, encrypting the command like in the following example fails saying Y95MgqDf...Bc=}: No such file or directory

after_deploy:
- secure: "Y95MgqDf...Bc="

Upvotes: 1

Views: 32

Answers (1)

vossad01
vossad01

Reputation: 11948

You don't encrypt the step. That does not appear to be supported by Travis.

Instead, encrypt only secret part:

$ travis encrypt TOKEN=verysecret
secure: "CnLZ...lI="

Put the secret in an environment variable:

env:
  global:
    secure: CnLZ...lI=

Then dereference the environment variable when you need your secret.

after_deploy:
- mycommand $TOKEN

Upvotes: 1

Related Questions