Cancel a pipeline when configured to auto cancel on first job failure
What does this MR do and why?
This is the second step of #23605 (closed).
- Add auto cancel pipeline on job failure syntax ... (!137815 - merged)
- <-- HERE -->
- Added documentation for workflow:auto_cancel:on... (!145709 - merged)
This MR uses the workflow:auto_cancel:on_job_failure
setting that was introduced in !137815 (merged) to stop the pipeline as soon as a job fails.
Screenshots or screen recordings
How to set up and validate locally
Set up a pipeline with the workflow:auto_cancel:on_job_failure
set to all
and to have more than one job, one of which has to fail.
The whole pipeline should be cancelled after the job fails.
This is an example .gitlab-ci.yml
stages:
- build
- test
- deploy
workflow:
auto_cancel:
on_job_failure: all
build-a:
stage: build
script:
- echo "Building a..."
- sleep 5
- echo "Done"
build-b:
stage: build
script:
- echo "Building b..."
- exit 1
build-c:
stage: build
script:
- echo "Building c..."
- sleep 5
- echo "Done"
build-d:
stage: build
script:
- echo "Building d..."
- sleep 5
- echo "Done"
build-e:
stage: build
script:
- echo "Building e..."
- sleep 5
- echo "Done"
lint:
stage: test
script:
- echo "Linting..."
- echo "Done"
deploy:
stage: deploy
script:
- echo "Deploying..."
- echo "Done..."
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Marco Zille