How to stop deployment to Heroku in progress
Asked Answered
L

3

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.

Lobscouse answered 31/1, 2017 at 14:44 Comment(1)
That's good question. I have 5 deploys same time, never seen it's happedMilford
C
90

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.

Cyrillic answered 22/1, 2019 at 16:19 Comment(0)
L
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.

Lobscouse answered 20/10, 2017 at 9:22 Comment(7)
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.Paediatrics
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 dayShearwater
I’m not sure - I think it should fail the build but I will report back once I test it.Paediatrics
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.Paediatrics
The deploy will fail if the release task fails: devcenter.heroku.com/articles/…Iraqi
It appears there may be some sort of watchdog timer as I tried what @Paediatrics said and it took ~ 5 mins before the web process shut down and re-attached the new buildCrumpler
Link is now in help.heroku.com/Z44Q4WW4/how-do-i-stop-a-release-phaseHornblende
C
2

I used the command

heroku builds:cancel -a <your_app_name>

and this worked for me

Cetinje answered 8/10, 2020 at 16:43 Comment(1)
Same here. Didn't have the build number to hand and it was useful to quickly just cancel.Nil

© 2022 - 2024 — McMap. All rights reserved.