smurf
smurf

Reputation: 349

How do I use travis encrypt to encrypt browserstack key?

I am having trouble getting my browserstack credentials to work on Travis. The credentials work locally if I don't encrypt the key and trigger the build from my local by just using environment variables.

I am using travis encrypt, which is instructed here: https://docs.travis-ci.com/user/browserstack/ but I am not sure I am using it correctly and am having difficulty finding documentation on the command.

If my browserstack key is foo, should the command be:

travis encrypt foo

travis encrypt BROWSERSTACK_ACCESS_KEY=foo

travis encrypt BROWSERSTACK_ACCESS_KEY="foo"

or something else? I am using the output of the command and putting it at the end of my .travis.yml like so:

addons:
  browserstack:
    username: "myusername"
    access_key:
      secure: "encryptedkey"

But I am consistently getting Browserstack access_key is invalid. in my Travis build.

Upvotes: 2

Views: 293

Answers (1)

brujoand
brujoand

Reputation: 855

Since Travis uses bash to evaluate this (iirc) you should use single quotes instead as bash will not expand special characters within single quotes. And you could probably also wrap the whole thing in double quotes for good measure, so this should work:

travis encrypt "BROWSERSTACK_ACCESS_KEY='foo'"

Also, if I understand your use of this secret correctly you should do something like this instead to configure the addon:

secure: "$BROWSERSTACK_ACCESS_KEY"

Upvotes: 1

Related Questions