How to Cache Dependencies in Bitbucket Pipelines
The caches key restores a dependency directory at step start and saves it at the end.
Use the built-in node cache or define a custom cache by path, then list it under a step caches key so installs reuse the prior download.
Built-in and custom caches
Reference the built-in node cache, and define a custom cache for any other directory.
bitbucket-pipelines.yml
definitions:
caches:
npm: ~/.npm
pipelines:
default:
- step:
name: Install and test
caches:
- node
- npm
script:
- npm ci
- npm testNotes
- The node cache is built in and targets node_modules; npm here is a custom cache for the download cache.
- Caches are keyed by name and branch fallback; they are best-effort, not guaranteed hits.
- Caches over 1 GB are dropped, so cache the download dir rather than huge build outputs.
Related guides
How to Run a Parallel Step Set in Bitbucket PipelinesRun multiple Bitbucket Pipelines steps at once with a parallel block, so lint, unit, and build steps execute…
How to Use a Custom Docker Image in Bitbucket PipelinesRun Bitbucket Pipelines steps inside a custom Docker image, setting image globally or per step and authentica…