# Setting environment variable from script command for later use in cache name

**URL:** <https://discuss.circleci.com/t/setting-environment-variable-from-script-command-for-later-use-in-cache-name/24036>\
**Category:** Build Environment\
**Created:** [August 3, 2018, 9:52am UTC](https://discuss.circleci.com/t/setting-environment-variable-from-script-command-for-later-use-in-cache-name/24036 "2018-08-03T09:52:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [August 3, 2018, 10:25am UTC](https://discuss.circleci.com/t/setting-environment-variable-from-script-command-for-later-use-in-cache-name/24036/2 "2018-08-03T10:25:33Z")

</div>

In [the docs](https://circleci.com/docs/2.0/caching/), there’s this info:

> The environment variable `variableName` (supports any environment variable [exported by CircleCI](https://circleci.com/docs/2.0/env-vars/#circleci-environment-variable-descriptions) or added to a specific [Context](https://circleci.com/docs/2.0/contexts)—not any arbitrary environment variable).

However, all is not lost; you can use a file instead. In your version capture:

```
echo $CYPRESS_VERSION > /tmp/cypress-version

```

Then in your restore keys:

```
- cy-{{ checksum "/tmp/cypress-version" }}

```

---

_[View the full topic](https://discuss.circleci.com/t/setting-environment-variable-from-script-command-for-later-use-in-cache-name/24036)._
