Cache restore by CIRCLE_NODE_INDEX?



I have a parallel build that builds JS in one node and Go/C++ in another. I’d like to be able to cache the yarn-cache in the JS node, but I don’t see a way to specify $CIRCLE_NODE_INDEX for cache-store steps. Is this possible? Or can $CIRCLE_NODE_INDEX be made on of the possible cache key components? Otherwise there’s a 50/50 chance I’ll write an empty yarn-cache, depending on which half of the build finishes first.

Alternatively, is it possible to specify more than one build per repository? Then I could just run these separately.


You should be able to specify {{$CIRCLE_NODE_INDEX}} as part of the cache name. That should solve it.


Great! Might be good to note in the config doc that env vars can be referenced in braces in addition to the suported runtime values. Thanks!



Error computing cache key: template: cacheKey:1: undefined variable “$CIRCLE_NODE_INDEX”


That took a dark turn. I’ll open a bug about that.


is it just golang templates with some struct representing build info? maybe you can add an env function so can do something like:


Thanks for the speedy help.


Is there an ETA or status update for this ticket?



No, not yet.


Hi, you can do {{ .Environment.CIRCLE_NODE_INDEX }}. This is documented here now.

We will probably improve the syntax but this should work for you now.



Great, thanks for following up!


works great