phallstrom / slackistrano

Slack integration for Capistrano deployments.
MIT License
373 stars 74 forks source link

Send a message on starting #93

Closed krim closed 5 years ago

krim commented 5 years ago

It's better to send a message to a slack channel on starting instead of updating. Starting is the first part of the deploying process.

I'll try to explain the changes. We have many developers and we don't want to conflict on deploy. First steps in our process deployment are:

This causes to us delay for 1.5 minutes before starting deploy in the console and the message in the channel.

phallstrom commented 5 years ago

@krim So it's been awhile since I've thought about this, but I think the reason I went with updating and not starting is that the latter includes various pre-checks which could fail (bad ssh, etc..) leaving others potentially confused by a starting message without any finished/failed message. My memory is there's no hook to tie into then post a "pre deploy checks failed" sort of message.

I can totally see your side of the coin though. Curious if you have thoughts on the above?

krim commented 5 years ago

@phallstrom I see your point. When something went wrong(wrong ssh key etc.) we will have a failed message after a starting message. I think that's really that we need to have. E.g. why we have failed message without starting? It looks like strange 'cause something has to be started before failed.

Some examples:

phallstrom commented 5 years ago

@krim - Oh... you get a failure message if deploy:check fails (sadly, I don't use capistrano nearly as much as I used to so may have missed this)? I don't think it used to do it that way, but if it does... then this seems like a good solution. I'll try and give it a serious look soon.

krim commented 5 years ago

More details here.

image

krim commented 5 years ago

@phallstrom Hello, have you got any news?

phallstrom commented 5 years ago

@krim - Sorry, got busy. So... playing around with this the problem is that if deploy:check fails (ie, bad ssh host, can't make directories, etc) then we'll have already sent out a message to Slack about it starting, but there's no way to send a "it failed" as capistrano exits (at least it does if the ssh host is bad, on 3.8.1).

That makes me hesitant to make this the default behavior, but maybe I'm too worried about the setup and once it's fine it would make more sense to have it sooner?

Alternatively we could take what you'd done and provide the hook, but not enable it and you could use a custom class to send a starting message.

Thoughts?

phallstrom commented 5 years ago

@krim scratch that. It does send a failure message. Well that's a nice addition! I'll look at getting this in place and shipped.

phallstrom commented 5 years ago

Went with a slightly different implemention. https://github.com/phallstrom/slackistrano/commit/ca040cbf3705c9ee65f75546331e59d083e67aee

phallstrom commented 5 years ago

@krim 4.0.1 was released just now and should do what you want. Note it will include both a starting and updating message, but you could silence the second via a custom messaging class. Occurs to me you may want it to know both when things started and when you're really doing the update and not the pre-check stuff.

Thanks!