Environment variable in checksum


It seems environment variables are not available in the {{ checksum “filename” }} template. The filename that I want to checksum depends on an environment variable… Is there any way for this to work?


Just echo the contents of the env var into a file and get the checksum.


I can’t figure out how to make that work.

This is what I’m trying, but it generates a different checksum every time. Are there any hidden salts involved?

- run: pushd base && git_rev_base=$(git describe HEAD) && popd && echo $git_rev_base >git-rev-base
      - restore_cache:
            - build-{{ checksum "git-rev-base" }}


Try echoing $git_rev_base to see what you’re dealing with.

Add another restore key to always get a restore:

  - build-{{ checksum "git-rev-base" }}
  - build-


Oh dear, thank you for stating the obvious! Sometimes a second pair of eyes really helps. :slight_smile: Apparently it’s running git describe head on the main repo rather than the submodule. I’m not sure why that should be the case (as it works just fine locally) but I can work with that.


Figured I should add, the key was that the submodule hadn’t been git inited and git updated yet. Alternatively one could use something like git submodule status base >git-hash-base.