Can I use variables in cache paths?



Using yarnpkg, I want to save the yarn’s cache dir.
The path depends on the environment (~/.cache/yarn, ~/.yarn-cache or …) and it’s available by yarn cache dir, so I want to use variables in paths.
I tried following 3 ways, but I didn’t get expected result.

- save_cache:
    key: v1-{{ epoch }}
      - $(yarn cache dir)
- save_cache:
    key: v1-{{ epoch }}
- save_cache:
    key: v1-{{ epoch }}
      - {{ .Environment.YARN_CACHE_DIR }}

Is there any other way?


I would run the image, echo out yarn cache dir and set that string in the config.


Do you recommend “hard coding” in config.yml?

I’ll show you another issue.
store_test_results of Full Example doesn’t work.
TEST_REPORTS in environment is /tmp/test-reports, but different dir /tmp/test-results is uploaded as test results.

      TEST_REPORTS: /tmp/test-reports
      - store_test_results:
          path: /tmp/test-results

This mistake is caused by “hard coding” and “copy/paste”.
If environment variables are available in path of store_test_results, such a problem does not occur.

      - store_test_results:
          path: $TEST_REPORTS


Yes, hardcode it in your config. We’re working on better env var support throughout the config but variables are still not evaluated everywhere you may think they are.


Thank you for your prompt reply!
I’m waiting for the implementation.


I’ve changed the category to “2.0 Feature Requests”.


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.