# Script can't find secure environment variable

**URL:** <https://travis-ci.community/t/script-cant-find-secure-environment-variable/5242>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** env-vars\
**Created:** [September 29, 2019, 8:27am UTC](https://travis-ci.community/t/script-cant-find-secure-environment-variable/5242 "2019-09-29T08:27:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![CJDennis](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/cjdennis/32/2796_2.png) [@CJDennis](https://travis-ci.community/u/CJDennis)\
**Post date:** [September 29, 2019, 8:27am UTC](https://travis-ci.community/t/script-cant-find-secure-environment-variable/5242/1 "2019-09-29T08:27:14Z")

</div>

I’m trying to add a mutation badge to my GitHub repository. I’ve followed the various instructions I’ve found online, and Travis CI builds successfully, including running the Infection mutation tests, which all pass. The output of the most recent run (as of writing) is found at:

[https://travis-ci.com/CJDennis/hidden-value/jobs/240107767](https://travis-ci.com/CJDennis/hidden-value/jobs/240107767)

At the bottom it says:

> `Dashboard report has not been sent: neither INFECTION_BADGE_API_KEY nor STRYKER_DASHBOARD_API_KEY were found in the environment`

This is why the badge is failing, but I don’t know why environment variable I encrypted in the `.travis.yml` file can’t be found.

I’ve tried a lot of different options and I no longer want to pollute my Git repository with failed experiments.

```auto
env:
  global:
    secure: "CPPE...3nk="

```

I tried both with and without a dash before `secure`, double quotes, single quotes, and no quotes. nothing has changed the output yet.

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [September 29, 2019, 9:15am UTC](https://travis-ci.community/t/script-cant-find-secure-environment-variable/5242/2 "2019-09-29T09:15:24Z")

</div>

According to [https://travis-ci.com/CJDennis/hidden-value/jobs/240107767#L168](https://travis-ci.com/CJDennis/hidden-value/jobs/240107767#L168), the value encrypted in the `env: global: secure:` in your `.travis.yml` is:

> ```
> qQVHLRNWJ1ir2GoJdetL6dg1caIIykzaFo3nk=<some value>
> 
> ```

which is probably not what you want.

Make sure you follow [Environment Variables - Travis CI](https://docs.travis-ci.com/user/environment-variables/#encrypting-environment-variables). In particular, since you have two secret variables, there’s going to be two encrypted values.

---

<div class="post-metadata">

**Author:** ![CJDennis](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/cjdennis/32/2796_2.png) [@CJDennis](https://travis-ci.community/u/CJDennis)\
**Post date:** [September 29, 2019, 11:13am UTC](https://travis-ci.community/t/script-cant-find-secure-environment-variable/5242/3 "2019-09-29T11:13:59Z")

</div>

Thanks! That’s exactly what I followed, except the variable shouldn’t be in `env.matrix`, so I left that as the default. I only need one of the two keys. The value is identical.

Any idea why the instructions have given weird results?

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [September 29, 2019, 12:30pm UTC](https://travis-ci.community/t/script-cant-find-secure-environment-variable/5242/4 "2019-09-29T12:30:51Z")

</div>

I’ve just tested it, [and it gave the expected results](https://travis-ci.org/native-api/test_travis/jobs/591084914#L120).

Since your build is at [https://travis-ci.com](https://travis-ci.com), I guess you didn’t specify the `--com` switch to `travis encrypt`.

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [September 29, 2019, 12:43pm UTC](https://travis-ci.community/t/script-cant-find-secure-environment-variable/5242/5 "2019-09-29T12:43:40Z")

</div>

> <https://github.com/travis-ci/docs-travis-ci-com/pull/2537>

---

<div class="post-metadata">

**Author:** ![CJDennis](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/cjdennis/32/2796_2.png) [@CJDennis](https://travis-ci.community/u/CJDennis)\
**Post date:** [September 29, 2019, 1:10pm UTC](https://travis-ci.community/t/script-cant-find-secure-environment-variable/5242/6 "2019-09-29T13:10:18Z")

</div>

I’ve relogged in with `--com`, regenerated a key with `travis encrypt STRYKER_DASHBOARD_API_KEY=<my-secret-uuid> --add` and pushed it, but I’m getting the same error:

> `$ export vpMINtGAqmBNx75KfK5waY1Je0=[secure]`

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [September 29, 2019, 1:55pm UTC](https://travis-ci.community/t/script-cant-find-secure-environment-variable/5242/7 "2019-09-29T13:55:19Z")

</div>

> [@CJDennis](#):
>
> regenerated a key with `travis encrypt STRYKER_DASHBOARD_API_KEY=<my-secret-uuid> --add`

You need to encrypt with `--com`, too. See [Encryption keys - Travis CI](https://docs.travis-ci.com/user/encryption-keys#usage).  
(that article uses `--pro`, it’s the same as `--com`. See `travis encrypt --help` for all the options available).

---

<div class="post-metadata">

**Author:** ![CJDennis](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/cjdennis/32/2796_2.png) [@CJDennis](https://travis-ci.community/u/CJDennis)\
**Post date:** [September 29, 2019, 2:02pm UTC](https://travis-ci.community/t/script-cant-find-secure-environment-variable/5242/8 "2019-09-29T14:02:56Z")

</div>

You are correct. `travis encrypt --pro STRYKER_DASHBOARD_API_KEY=<my-secret-uuid> --add` did the trick!
