Cache plugin for buildkite?

Hi all, I am currently trying to set up a caching mechanism to improve the pipelines of my NodeJs application.
For example, this is how I am currently using it in Github actions for my open source repositories.

   - name: Get yarn cache directory path
    id: yarn-cache-dir-path
    run: echo "::set-output name=dir::$(yarn cache dir)"

  - uses: actions/cache@v2
    id: yarn-cache
      path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
      key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
      restore-keys: |
        ${{ runner.os }}-yarn-

What is the recommended way to do this using buildkite? I could not find any information in the documentation. Thanks!

We’ve built a plugin internally just for this purpose (save/restore yarn & npm cache between builds):

1 Like

We don’t have an official caching method that’s equivalent to GitHub Actions approach, but there’s a number of plugins that work in a similar way.

@vitalii’s plugin is a good option. Another I’ve seen folks get positive results with

Searching for “cache” on might turn up some other options.

Sidenote: @vitalii - it’d be great to have peakon’s plugin listed in the plugin directory! If you’re up for it, there’s some instructions here:


I’m using the gencer/cache plugin.
My config looks like this.

cache_plugin_config: &cache_plugin_config
  backend: tarball
  key: "deps-{{ checksum 'yarn.lock' }}"
    path: '/tmp/buildkite-cache'
    max: 7 # Optional. Removes tarballs older than 7 days.
    - ./node_modules/
    - ./packages/*/node_modules

  - label: ':eslint:'
      - './ci yarn install --frozen-lockfile'
      - './ci yarn lint:web'
      - gencer/cache#v2.3.3: *cache_plugin_config

  - label: ':jest:'
      - './ci yarn install --frozen-lockfile'
      - './ci yarn test:web --ci'
      - gencer/cache#v2.3.3: *cache_plugin_config

You can find more plugins here:

1 Like