Lesstep
Bitbucket Cloud · Pipelines · Checked October 31, 2026

Bitbucket Pipelines: stopping older pipelines on a new push

Push twice to a branch or a pull request, and Bitbucket runs both pipelines to the end, spending build minutes on the commit nobody needs any more. Bitbucket has no setting to cancel the older one. You can stop it by hand, or have the new pipeline stop it through the API, as Atlassian's support suggests.

No automatic cancel

Atlassian's support has said so in its community: "there is no automated way to do that" (February 2023), and Bitbucket Pipelines "does not natively support automatically canceling a running pipeline" for a pull request (December 2024). Two feature requests are open, both Gathering Interest:

A pipeline started with the atlassian/trigger-pipeline pipe is not stopped either when the pipeline that started it is (BCLOUD-23527).

Stop a pipeline

On Bitbucket, stop it from the running pipeline's page. With the REST API, Stop a pipeline:

curl -X POST -u '<email>:<API token>' \
  https://api.bitbucket.org/2.0/repositories/WORKSPACE/REPO/pipelines/{PIPELINE_UUID}/stopPipeline

Let the new pipeline stop the old ones

The steps Atlassian's support suggested, for a step at the start of the pipeline:

  1. List the newest pipelines of the same branch ($BB_AUTH being email:API token):
    curl -u "$BB_AUTH" "https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_FULL_NAME/pipelines/?target.branch=$BITBUCKET_BRANCH&sort=-created_on&pagelen=20"
  2. Keep those whose state.name is PENDING or IN_PROGRESS and whose build_number is lower than $BITBUCKET_BUILD_NUMBER, so the pipeline never stops itself or a newer one.
  3. Send stopPipeline for each uuid. A 400 only means that one finished in the meantime.

Queue instead of cancel: concurrency groups

Since June 2025, a step can name a concurrency-group (Atlassian's announcement). Only one step of a group runs at a time, first in, first out, across pipelines; the others wait as Waiting to run. That keeps two runs of a deployment apart, but it does not stop the older one: every pipeline still runs.

Stop pipelines from IntelliJ IDEA

Pipeline Inbox for Bitbucket Pipelines, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the pipelines of all your Bitbucket Cloud repositories in an IDE tool window, with a running filter for those still waiting, running or paused at a manual step, and your current branch's pipeline in the status bar. Stop Pipeline on a running pipeline sends the same stopPipeline, so an outdated run on your branch can be stopped without opening Bitbucket. It does not stop pipelines by itself. The list, steps and logs are free; running, running again and stopping are Pro (US$1.50 a month, with a 30-day trial).

Get it on JetBrains Marketplace

Atlassian, Bitbucket and Bitbucket Pipelines are trademarks of Atlassian; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Atlassian or JetBrains.

More: Rerun a failed pipeline · Run a custom pipeline with variables · Out of build minutes · "No online runner available" · "Permission denied to update branch" · "You have reached your pull rate limit" (Docker Hub) · "There is an error in your bitbucket-pipelines.yml" · "This pipeline was paused" (deployments) · Bitbucket Pipelines plugins for IntelliJ IDEA compared · 日本語