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 lintNotes
- 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
How to Run a Step with a Larger Size in Bitbucket PipelinesGive a memory-hungry Bitbucket Pipelines step more resources by setting size: 2x or higher so heavy builds ge…
How to Run after-script Cleanup in Bitbucket PipelinesRun teardown logic regardless of step outcome in Bitbucket Pipelines with after-script, which executes after…