Environment variables don't expand inside the `cache_directories` directive

Hello. I wanted to install the latest (at the moment) version of ElasticSearch, so I set up circle.ci as described in this guide — and it worked great. Then I decided to “DRY-out” repeated ElasticSearch version so it can be easily changed later. I modified my config to use the version defined via an environment variable:


    - elasticsearch-${ELASTIC_VERSION}
    - if [[ ! -e elasticsearch-${ELASTIC_VERSION} ]]; then wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTIC_VERSION}.tar.gz && tar -xzf elasticsearch-${ELASTIC_VERSION}.tar.gz; fi
    - elasticsearch-${ELASTIC_VERSION}/bin/elasticsearch:
        background: true

I pushed this change to the repo and waited until the build finished successfully, then rebuilt it twice, each time ElasticSearch was downloaded. Also, there was a warning:

circle.yml specified cache directory: /home/ubuntu/REPONAME/elasticsearch-${ELASTIC_VERSION} but it does not exist

So I’ve figured out that environment variables just don’t expand inside the cache_directories directive. I don’t know if it’s made by intention or just have not been implemented yet, but I think that it would be a nice feature to have, so I have decided to report this.


1 Like

We have also noticed this issue, seems weird that we can’t use variables in cache_directories.

Could you try this on 2.0?

Hello, @zzak. I have just requested 2.0 beta access and will try it as soon as I receive confirmation.

I have briefly read about the 2.0 features, and it seems like with 2.0 it is better to use the dedicated Docker image to get a specific version of ElasticSearch, so my original use-case does not longer apply. Can you clarify this?

You can run builds- it’s an open beta. Just update your configuration to the 2.0 syntax and your build will run on the new platform.

Yes, you can specify the latest tag on 2.0, solving your original issue.

Thanks, will try it as soon as I have free time!

1 Like

I am having the same problem with cache_directories on 1.0

I would try 2.0 but I am still trying to learn 1.0 and it would be too take too much time to switch to 2.0 just to solve this one problem.

(Though I do plan to switch to 2.0 once I get a full setup working on 1.0.)