Skip to content
Latchkey

How to Fail the Pipeline on Lint Errors in Bitbucket Pipelines

A lint step that exits non-zero fails the pipeline; put it before tests so a lint failure short-circuits cheaply.

Run the linter in its own step early in the pipeline. A non-zero exit fails the step (and the pipeline). Steps run in order, so a failed lint stops later steps.

Lint step before tests

The lint step runs first; its non-zero exit on errors stops the pipeline before the test step.

bitbucket-pipelines.yml
image: node:20

pipelines:
  default:
    - step:
        name: Lint
        script:
          - npm ci
          - npx eslint . --max-warnings=0
    - step:
        name: Test
        script:
          - npm test

Gotchas

  • Steps run sequentially by default - a failed lint step stops the ones after it, so order lint first.
  • ESLint exits non-zero on errors and fails the step; do not wrap the gating command in || true.
  • To run lint and test in parallel instead, put them in a parallel: block - but then a lint failure does not stop the test step.

Related guides

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