How to cancel a GitLab pipeline, and auto-cancel redundant ones
Short answer
In Build › Pipelines, select Cancel the running pipeline, or select Cancel on a job's log page; from a terminal, run glab ci cancel pipeline <id>. A running job shows canceling while its after_script finishes, and a Maintainer or Owner can Force cancel it. To stop outdated pipelines automatically, select Auto-cancel redundant pipelines in Settings › CI/CD › General pipelines and mark jobs that are safe to stop interruptible: true.
A deploy started for the wrong commit, a job that hangs, or three pipelines running because you pushed three times in a minute: here is how to cancel a GitLab pipeline or a single job, what happens to a job after you press Cancel, and how to make GitLab cancel outdated pipelines on its own.
Cancel it by hand
- A whole pipeline: go to Build › Pipelines, or the Pipelines tab of a merge request, and select Cancel the running pipeline next to it. That cancels every job in it that hasn’t finished.
- One job: select Cancel in the upper-right corner of the job’s log page, next to the job in the pipeline graph, or next to it in the merge request’s pipeline widget. Jobs in later stages, and jobs that list it in
needs, are skipped.
A canceled job can be retried later, like a failed one; Retry all failed or canceled jobs does it for the whole pipeline. See how to retry a failed GitLab pipeline.
What happens when you cancel a job
A job that hasn’t started yet is canceled immediately. A running job goes through a short shutdown:
- Its status changes to canceling.
- The command that is running is allowed to finish; the rest of
before_scriptandscriptis skipped. - If the job has an
after_script, it starts and runs to completion. Since GitLab 17.0,after_scriptruns for canceled jobs too, so cleanup code there must cope with a half-finishedscript. - The job is marked canceled.
after_script has its own timeout, 5 minutes by default, set with the RUNNER_AFTER_SCRIPT_TIMEOUT variable. That is usually why a job sits in canceling for a while.
Force cancel a job stuck in canceling
If you don’t want to wait for after_script, or the job has stopped responding, open the job’s log page and select Force cancel. The job goes straight from canceling to canceled, and its job token is revoked at once, so a runner still executing it loses access to GitLab and aborts without finishing after_script.
Force cancel needs the Maintainer or Owner role, and the job must be in the canceling state, which exists only on GitLab 17.0 or later with GitLab Runner 16.10 or later. On an older self-managed runner, upgrade the runner first.
Who can cancel
By default, users with the Developer, Maintainer or Owner role can cancel pipelines and jobs. On Premium and Ultimate, a Maintainer or Owner can change that in Settings › CI/CD › General pipelines under Minimum role required to cancel a pipeline or job: restrict it to Maintainers and Owners, or prevent cancelling altogether. If the Cancel button is missing for you, check that setting and your role first.
From the command line and the API
- GitLab CLI:
glab ci cancel pipeline 1504182795cancels a pipeline, andglab ci cancel job 1504182795a job. Both take several IDs, comma-separated or quoted, and--dry-runshows what would be canceled. For a job in a protected environment,glab ci cancel jobneeds--force. - API:
POST /projects/:id/pipelines/:pipeline_id/cancelcancels all jobs in a pipeline; it returns 200 whatever the pipeline’s state.POST /projects/:id/jobs/:job_id/cancelcancels one job.
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
"https://gitlab.example.com/api/v4/projects/<project_id>/pipelines/<pipeline_id>/cancel"
Cancel redundant pipelines automatically
Each push starts a pipeline, and usually only the newest matters. With Auto-cancel redundant pipelines selected in Settings › CI/CD › General pipelines, GitLab cancels the older pending or running pipelines when a pipeline for a new commit starts on the same branch. It reacts to new commits only: starting New pipeline again for the same commit cancels nothing.
Which running jobs it may stop is up to you. Mark the ones that are safe to stop halfway, like builds and tests:
test:
stage: test
script:
- make test
interruptible: true
interruptible defaults to false. Under the default mode, a job that hasn’t started counts as interruptible whatever it says; the setting only matters once a job runs. After a job with interruptible: false starts, the whole pipeline can no longer be auto-canceled, so keep deploys and database migrations at the default.
To let people protect a pipeline by hand, add an optional manual job with interruptible: false in the first stage. Once someone starts it, auto-cancel leaves that pipeline alone:
keep-this-pipeline:
stage: .pre
script:
- echo "This pipeline won't be auto-canceled."
when: manual
allow_failure: true
interruptible: false
Choose how aggressive auto-cancel is
workflow:auto_cancel:on_new_commit decides what a newer commit cancels:
| Value | What gets canceled |
|---|---|
conservative (default) |
The pipeline, but only if no job with interruptible: false has started yet |
interruptible |
Only the jobs marked interruptible: true; the others keep running |
none |
Nothing |
If you’d rather stop the tests and let a running deploy finish, use interruptible:
workflow:
auto_cancel:
on_new_commit: interruptible
Downstream pipelines follow their own jobs: under the default, a downstream pipeline is canceled with its parent only if none of its own interruptible: false jobs has started, and a trigger job’s interruptible setting never affects the pipeline it triggered.
Stop everything when one job fails
workflow:auto_cancel:on_job_failure: all cancels the pipeline and all running jobs as soon as one job fails, so you stop spending compute minutes on jobs whose result no longer matters. The default, none, lets them finish.
workflow:
auto_cancel:
on_job_failure: all
Cancel from your phone
A runaway job tends to show up when you’re away from your desk. In MergeBell, the free tier opens pipelines with live job logs and lets you cancel, retry or play a manual job with your own GitLab token and its permissions; with Pro, a pipeline watch on a branch pushes when its pipeline fails.
Frequently asked questions
How do I cancel a running pipeline in GitLab?
Go to Build › Pipelines (or the Pipelines tab of a merge request) and select Cancel the running pipeline next to it. To stop one job, select Cancel on the job's log page, next to the job in the pipeline graph, or in the merge request's pipeline widget. From a terminal, run glab ci cancel pipeline with the pipeline ID.
Why is my GitLab job stuck in canceling?
A running job you cancel moves to canceling: the command that is running finishes, the rest of the script is skipped, and after_script runs to completion before the job is marked canceled. after_script has its own timeout, 5 minutes by default. If you can't wait, a Maintainer or Owner can select Force cancel on the job's log page; that needs GitLab 17.0 and GitLab Runner 16.10 or later.
Who can cancel a GitLab pipeline?
By default, users with the Developer, Maintainer or Owner role. On Premium and Ultimate, Settings › CI/CD › General pipelines › Minimum role required to cancel a pipeline or job can limit it to Maintainers and Owners, or prevent cancelling entirely. Force cancel always needs Maintainer or Owner.
How do I make GitLab cancel old pipelines when I push again?
Select Auto-cancel redundant pipelines in Settings › CI/CD › General pipelines. When a pipeline for a new commit starts on the same branch, GitLab cancels the older pending or running pipelines, but under the default conservative mode only while no job with interruptible: false has started. Mark jobs that are safe to stop interruptible: true. Running New pipeline again for the same commit doesn't trigger it.
Can GitLab cancel the whole pipeline when one job fails?
Yes. Set workflow:auto_cancel:on_job_failure to all, and GitLab cancels the pipeline and all running jobs as soon as one job fails. The default, none, lets the other jobs keep running.
Sources
- GitLab docs — CI/CD Jobs: cancel and force cancel jobs
- GitLab docs — Customize pipeline configuration: auto-cancel and cancel permissions
- GitLab docs — CI/CD YAML syntax reference: after_script, interruptible and workflow:auto_cancel
- GitLab docs — Deprecations and removals: after_script runs for canceled jobs (17.0)
- GitLab docs — Pipelines API
- GitLab docs — Jobs API
- GitLab CLI docs — glab ci cancel job
- GitLab docs — Roles and permissions
Checked against these pages on 25 November 2026. GitLab changes quickly — if something here no longer matches, tell us and we will fix it.
Do this from your phone with MergeBell
Free for the whole review loop: the To-Do inbox, diffs and line comments, approve and merge, pipelines with retry, and push alerts for your To-Dos. Works with gitlab.com and self-managed GitLab 16.0+.
Get MergeBell for iPhoneGet MergeBell for Android
On the App Store for iOS 26 or later and on Google Play for Android 12 or later. An independent app, not affiliated with GitLab Inc.