Cache restore by CIRCLE_NODE_INDEX?

cache
paralellism
circle.yml

#1

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.


#2

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


#3

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!


#4

nope:

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


#5

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


#6

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

{{ env “CIRCLE_NODE_INDEX” }}

Thanks for the speedy help.


#7

Is there an ETA or status update for this ticket?

THANKS!


#8

No, not yet.


#10

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.

Thanks!


#11

Great, thanks for following up!


#12

works great


#13