Can I use variables in cache paths?

cache
yarn

#1

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 }}
    paths:
      - $(yarn cache dir)
- save_cache:
    key: v1-{{ epoch }}
    paths:
      - $YARN_CACHE_DIR
- save_cache:
    key: v1-{{ epoch }}
    paths:
      - {{ .Environment.YARN_CACHE_DIR }}

Is there any other way?


#2

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


#3

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.

    environment:
      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

#4

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.


#5

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


#6

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


#7

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