CircleCI Ideas

Add time calculated keys for save_cache

I tried doing this in my .circleci/config.yml

- restore_cache:
    keys:
      - dependency-check-data-{{ epoch / 604800000 }} #Roughly a week

It failed.

My hope is that I can cache some files for only a week (rather than the circleci default 30 days)

I'm not sure how to do a week-long cache with the tools provided: https://circleci.com/docs/2.0/caching/

 

Or perhaps if I need some other duration. Maybe I can cache something for 24 hours and deploy with it several times a day.

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • Dec 2 2019
  • New
  • Attach files
  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    02 Dec 23:13
  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    02 Dec 23:23

    I ended up doing this.

    - run:
        name: Generate cache key
        command: date --date="7 days ago" +"%Y-%V" | tee .circle-last-week && date +"%Y-%V" | tee .circle-this-week
    - restore_cache:
        keys:
          - 'dependency-check-data-{{ checksum ".circle-last-week" }}'
          - 'dependency-check-data-{{ checksum ".circle-this-week" }}'
    - run: ./gradlew dependencyCheckAnalyze
    - store_artifacts:
        path: ./build/reports/owasp
    - save_cache:
        paths:
          - ~/.gradle
        key: 'dependency-check-data-{{ checksum ".circle-this-week" }}'


    Would be nice to see this sort of thing in the product.