How to cancel a Heroku build


TL;DR: cancel the latest Heroku build:

heroku builds:cancel -a $APP_NAME

Prerequisite

Install the Heroku Builds plugin:

heroku plugins:install heroku-builds

List Builds

List the builds for $APP_NAME:

heroku builds -a $APP_NAME

See more builds:

heroku builds -a $APP_NAME -n 50

Get the latest build id:

heroku builds -a $APP_NAME | awk 'NR==4{print $1}'

Cancel Build

Cancel build given $APP_NAME and $BUILD_ID:

heroku builds:cancel $BUILD_ID -a $APP_NAME

Cancel the latest build:

heroku builds:cancel -a $APP_NAME

Which is the same thing as:

heroku builds:cancel $(heroku builds -a $APP_NAME | awk 'NR==4{print $1}') -a $APP_NAME

Help

View the help documentation:

heroku builds:cancel --help
cancel a running build

USAGE
  $ heroku builds:cancel [BUILD]

OPTIONS
  -a, --app=app        (required) app to run command against
  -r, --remote=remote  git remote of app to use

DESCRIPTION
  Stops executing a running build. Omit BUILD to cancel the latest build.


Please support this site and join our Discord!