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 testGotchas
- 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
How to Fail the Build on Lint Errors in GitHub ActionsMake a GitHub Actions job fail on lint errors by running the linter with a non-zero exit, and surface finding…
How to Run Parallel Steps in Bitbucket PipelinesRun steps in parallel in Bitbucket Pipelines with the parallel: keyword to fan out test and lint steps and cu…