Capistrano - label deployment failed

I am using Capistrano 3.

I want to start a webhook for an external service when my deployment fails.

It is a matter of calling a method that I have already defined, let's call it mark_failed

.

How can I ensure that the method is always called when the deployment fails for any reason other than aborting it with CTRL + C?

Tried messing around with

rescue SystemExit, Interrupt

and rescue StandardError

I have no idea where to put my method so that it is called reliably.

Any hints?

+3


source to share


1 answer


I would suggest using at_exit

.



at_exit do
   mark_failed if $!
end
raise "Something is wrong!"

      

+2


source







All Articles