Closed richardtape closed 8 years ago
So you want to send a notification to slack after some specific cap task runs with your own messaging?
Pretty much. Instead of one of the default Capistrano tasks (deploy, db, logging etc.) it'd be great to be able to use this from custom rake tasks.
Interesting. It's possible, kind of a PITA in it's current form, but I have some other things I want to do that might make it easier to add your own hooks as well.
@richardtape I was able to get custom slack messages within cap a task by setting
:slack_run_CUSTOM , -> {true}
:slack_msg_CUSTOM, -> { "Custom Message" }
then calling Slackistrano::Capistrano.new(self).run(:CUSTOM)
So my rake task looks like:
# Migrations Code
set :slack_run_migrated, -> {true}
set :slack_msg_migrated, -> { "Migrations ran by #{fetch :slack_deploy_user}" }
Slackistrano::Capistrano.new(self).run(:migrated)
Working on an overhaul (overhaul
branch) that will let you do this in a slightly different manner. Configuration has changed to let you specify a class that handles messaging. So you'd do something like this:
set :slackistrano, {klass: CustomMessaging, ...}
And the class would look look like this:
class CustomMessaging < Slackistrano::Messaging::Default
def message_for_migrated
{text: "Migrations ran by #{deployer}"}
end
end
Then you just need to put Slackistrano::Capistrano.new(self).run(:migrated)
wherever you want it to run.
3.1.0.beta just went to rubygems. Should be 100% backward compatible. Also includes info on how to customize to your heart's content. https://github.com/phallstrom/slackistrano#customizing-the-messaging
Thanks so much for this, we're using it for our deploys and rollbacks. However, as the title implies, I'm wondering if this can be set up to work on custom tasks. We have a custom 'migration' task which I'd like to send to slack.