Skip to content
Latchkey

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_TOKEN as 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

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