phallstrom / slackistrano

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

Handle cap deploy:rollback? #19

Closed vendruscolo closed 8 years ago

vendruscolo commented 9 years ago

I had to rollback to a previous revision (cap production deploy:rollback) and Slackistrano correctly posted a message (I use slackbot) to the channel.

This is how I configured it in deploy.rb

set :slack_msg_finished, ->{ "Finished deploying branch `#{fetch :branch}` to *#{fetch :stage}*.\n\nLast commit:\n#{%x[git show -s --format=%B #{fetch :branch}]}" }

(I really like it, because I can embed changelogs in commits! Combined with git flow it's a win-win)

But, for a rollback that's totally wrong, because no branch is involved (also, those commands get executed locally on my machine, so that's not the point).

What I'm asking you is whether you think it can be improved to also support —somehow— rollbacks. I don't know if it's feasible to retrieve the version that we'll rollback to, but at least I think we could have something similar to this

set :slack_rollback_msg_finished, ->{ "Finished rollback" }

Any idea?

phallstrom commented 9 years ago

Interesting. It could be done by adjusting the after hooks and when they get called.

https://github.com/supremegolf/slackistrano/blob/master/lib/slackistrano/tasks/slack.rake#L77 https://github.com/supremegolf/slackistrano/blob/master/lib/slackistrano/tasks/slack.rake#L77

Can you look to see what hooks get called when during a rollback? If you can get me that I can see about tweaking functionality to allow for this.

vendruscolo commented 9 years ago

During a rollback, tasks are called in this order

deploy:starting deploy:started deploy:reverting - revert server(s) to previous release deploy:reverted - reverted hook deploy:publishing deploy:published deploy:finishing_rollback - finish the rollback, clean up everything deploy:finished

Doc: http://capistranorb.com/documentation/getting-started/flow/

I think you're looking for deploy:finishing_rollback, although that seems it should be used for cleanup?

phallstrom commented 9 years ago

Yeah, it looks like we'd have to adjust it to run on deploy:finishing and deploy:finishing_rollback. I'll have to look around to see what other tasks run then since this isn't a cleanup. Those are the only places that are different though :/

phallstrom commented 8 years ago

This has been incorporated into version 1.0.0, just released to rubygems. See the changelog for details.