How to stop deployment to Heroku in progress

Ole Henrik Skogstrøm picture Ole Henrik Skogstrøm · Jan 31, 2017 · Viewed 15.1k times · Source

Is it possible to stop a deploy to Heroku (git push heroku) that is currently being built?

Something like heroku run stopit!

Btw. rolling back after successful deploy is not what I'm looking for.

Answer

Elias Dorneles picture Elias Dorneles · Jan 22, 2019

First, install the Heroku builds plugin:

heroku plugins:install heroku-builds

Then, to cancel a build, fetch the list of the recent builds:

heroku builds -a YOUR_APP_NAME

The first line of the output will be your currently running build, the first column is the build ID.

Cancel it with:

heroku builds:cancel BUILD_ID -a YOUR_APP_NAME

Et voilà, this will force fail the build.

Note: you could also get the build id from the build log URL.