Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano - mark deployment as failed

I'm using Capistrano 3.

I want to trigger a webhook to a external service, when my deployment fails.

It's a matter of calling a method I have already defined, let's say it's called mark_failed.

How I can ensure the method is always called when the deployment fails, for whatever reason, except aborting it via CTRL+C ?

Tried fiddling around with

rescue SystemExit, Interrupt and rescue StandardError

I have no clue where to put my method call the way it will be called reliably.

Any clues ?

like image 332
astropanic Avatar asked Feb 10 '26 15:02

astropanic


1 Answers

I would suggest using at_exit.

at_exit do
   mark_failed if $!
end
raise "Something is wrong!"
like image 131
Salz Avatar answered Feb 12 '26 14:02

Salz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!