50

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.

Ole Henrik Skogstrøm
  • 6,353
  • 10
  • 57
  • 89

3 Answers3

86

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.

Elias Dorneles
  • 22,556
  • 11
  • 85
  • 107
3

I might have found an answer to this problem, it seems to have been answered by Heroku in May. I'm assuming that by release phase they mean deploy: https://help.heroku.com/Z44Q4WW4/how-do-i-stop-a-release-phase

Release Phase processes are the same as any other Dyno in your formation, expect they run the codebase from the new release, instead of your current release.

To monitor your Release Phase processes as they execute, you can use the CLI command heroku ps -a YOUR_APP_NAME. as these are normal processes, you can use the ps:kill and ps:scale commands to stop the Release Phase from completing, which in turn, will prevent the latest release from completing.

I haven't tested this yet, but i will update with my exact commands when i have tested it out. If any one tests this out and can confirm, please feel free to update this answer.

mrcasals
  • 1,151
  • 10
  • 20
Ole Henrik Skogstrøm
  • 6,353
  • 10
  • 57
  • 89
  • 1
    Release Phase runs at the conclusion of the build - it's a place where you'd put things like database migrations or asset compilation tasks. So I don't think you can use it to stop a build. You can certainly cancel it with `heroku ps` but by then the build will have finished successfully. – rubendinho Dec 09 '17 at 04:12
  • Wont the effect be that the build will not be used? Or will the new deploy be used? So that i still have to roll back? I should test this one day – Ole Henrik Skogstrøm Dec 10 '17 at 17:28
  • I’m not sure - I think it should fail the build but I will report back once I test it. – rubendinho Dec 11 '17 at 18:20
  • Just confirmed that a build will be used even if the release phase task fails. FWIW this is for a Rails app, with the release phase task a separate shell script that raised an exception inside a rake task. – rubendinho Dec 20 '17 at 16:18
  • The deploy will fail if the release task fails: https://devcenter.heroku.com/articles/release-phase#release-command-failure – tjmcewan Oct 04 '18 at 07:19
  • It appears there may be some sort of watchdog timer as I tried what @rubendinho said and it took ~ 5 mins before the web process shut down and re-attached the new build – ozzyaaron Oct 25 '18 at 16:58
  • Link is now in https://help.heroku.com/Z44Q4WW4/how-do-i-stop-a-release-phase – mrcasals Feb 22 '21 at 13:37
1

I used the command

heroku builds:cancel -a <your_app_name>

and this worked for me