Auto cancel on next build


It looks like I might have forgot to post this suggestion.

When CircleCi sees a new build request come in on the same branch, would it be possible to have it cancel prior running builds?

For me at least, I see a problem, go fix it, then have to come back and cancel the (hung/long) build in order for the queued one to fire.

This would save on containers and I can’t think of a use case where you would want multiple builds running on the same branch at one time (maybe a settings option if there are)?

Create a command line tool to interact with CircleCI REST API

Right now this is not possible—although if you feel like you need that for your workflow, you should be able to implement a build auto-canceller with this API endpoint.


+1 This would be very helpful in helping avoid builds getting queued up (especially if developers perform multiple commits on the same branch in a very short period of time).

Another related capability might be a wait configuration… i.e. if a new build request for the same branch comes in before the configured amount of time, use the latest code.


+1 - We use the same GitHub integrated workflow and this feature would very much help us avoid unnecessary queue buildups


+1, this would be extremely helpful, especially around release deadlines when there are multiple commits going into a branch in rapid succession. We end up having to constantly cancel builds manually to avoid the long queues.


+1 It’s great to have builds automatically running but in most cases on a singular branch it’s the most recent commit you are most interested in (only when it fails do you care about the builds between).

This causes resource hogging when that is not the intention of the developer, they are trying to do the right thing by pushing their code to the cloud for safe keeping and having tests run automatically.


-1 if it stops in the middle of a dependencies. test, deploy. We provision external resources sometimes that need to be torn down and have a multi stage deploy process with many intermediary states. Cancelling in the middle of a multi stage database migrations could be enormously painful to recover.

It’s okay to cancel a build is if it hasn’t started and optionally in-between stages. I can’t imagine a situation where it would be good for us to get cancelled at any random point.


+1. Asked for this a while ago.


Be sure to click on the little heart to show your support. We look at the issues with the most likes to determine the demand.


If this is of help to anyone, I’ve created a circleci command line helper script to address this problem, which allows you to cancel “redundant” builds to work around this problem. This is a django command, but could easily be extracted to run as a standalone command without Django. To run, simply use

./ circleci --cancel-redundant-builds

Happy about any feedback or bugs!


+1. Our team always talks about this


+1 for this. I’ve been manually pruning multiple builds per branch for a while thinking I’d dig out the appropriate config to make this work automatically. Pretty bummed to find it’s not implemented :frowning:

Ability to queue builds on the same branch

We have added functionality to auto-cancel redundant builds. If this feature is turned on, we will automatically cancel any queued or running builds on a branch when a newer build is triggered on that same branch. To enable this feature you can navigate to “Advanced Settings” for your project and enable the “Auto-cancel builds” option.


Woohoo! Thanks for adding :slight_smile:


Why doesn’t it apply to the default branch?