How to Generate and Store a Coverage Report in Bitbucket Pipelines
Produce coverage in the test step, then keep the report as an artifact or upload it to Codecov for PR annotations.
Bitbucket has no native coverage UI, so generate the report in the test step and either store it via artifacts: or push it to a service like Codecov.
Generate, store, and upload
The step runs coverage, keeps the HTML report as an artifact, and uploads lcov to Codecov.
bitbucket-pipelines.yml
pipelines:
default:
- step:
name: Test with coverage
image: node:20
script:
- npm ci
- npm test -- --coverage
- pipe: codecov/codecov-pipe:latest
variables:
CODECOV_TOKEN: $CODECOV_TOKEN
artifacts:
- coverage/**Gotchas
- Bitbucket has no built-in coverage tab - use
artifacts:for download or a service like Codecov for trends/PR comments. - Set
CODECOV_TOKENas a secured variable; the Codecov pipe needs it for private repos. - Artifacts are kept ~14 days and capped in size - they are for handoff, not long-term coverage history.
Related guides
How to Generate and Publish a Coverage Report in GitHub ActionsGenerate a code-coverage report in GitHub Actions and upload it to Codecov, or enforce a threshold and attach…
How to Pass Artifacts Between Steps in Bitbucket PipelinesPass build artifacts between steps in Bitbucket Pipelines with the artifacts: keyword and glob paths so a lat…