Skip to content
Latchkey

How to Use Parallel Steps with Caches in Bitbucket Pipelines

Parallel steps each pull the shared cache, so concurrency does not mean cold installs.

Group steps under parallel to run them at once. Add caches: to each step so every parallel branch restores dependencies instead of reinstalling from scratch.

Fan out tests with a shared cache

Each parallel step declares the node cache so installs are warm.

bitbucket-pipelines.yml
pipelines:
  default:
    - parallel:
        - step:
            name: Unit
            caches:
              - node
            script:
              - npm ci
              - npm run test:unit
        - step:
            name: Lint
            caches:
              - node
            script:
              - npm ci
              - npm run lint

Notes

  • The node cache is predefined; declaring it in each step restores ~/.npm or node_modules per Bitbuckets cache rules.
  • Parallel steps consume build minutes concurrently, so plan minute budgets accordingly.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →