I’m using Cypress for some testing in Circle CI and I’d like to be able to cache the downloaded binary so speed up the builds a little bit, and ideally that cache would be based on the installed version number so it “just works” across upgrades.
I’m attempting to extract the version number in one job, and then use it in another.
- run:
name: Extract Cypress version for cache name
command: |
CYPRESS_VERSION=$(yarn info cypress version | grep -v "DeprecationWarning" | sed -n "2p")
echo $CYPRESS_VERSION
echo 'export CYPRESS_VERSION=$CYPRESS_VERSION' >> $BASH_ENV
- restore_cache:
name: Restoring Cypress cache
keys:
- cy-{{ .Environment.CYPRESS_VERSION }}
I can see in the job output that it’s getting the correct value for the version, but on restoring the cache it says Found a cache from build 1476 at cy-<no value>
which, oddly enough, isn’t the correct version number.
Current hypothesis is that the $BASH_ENV
environment variables aren’t the same as the .Environment
ones, which does make sense. Is it possible to use bash env vars in cache names?