phallstrom / slackistrano

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

Consider some formatting by default #27

Closed bradgreens closed 8 years ago

bradgreens commented 9 years ago

The strings slackistrano currently sends to slack are cough kinda boring. Here's how our config looks:

# In our app it seems we needed to coerce this line. 
set :rails_env, fetch(:stage)

set :slack_webhook, YAML.load_file('./config/slackistrano.yml')["web_hook_url"]

emoji = :rails_env == 'production' ? ':ship:' : ':fireworks:'
set :slack_icon_emoji, emoji

set :slack_msg_starting, "*#{fetch :slack_deploy_user}* has started deploying branch `#{fetch :branch}` of `#{fetch :application}` to `#{fetch :rails_env, 'production'}`"
set :slack_msg_finished, "*#{fetch :slack_deploy_user}* has finished deploying branch `#{fetch :branch}` of `#{fetch :application}` to `#{fetch :rails_env, 'production'}`"
set :slack_msg_failed,   "*#{fetch :slack_deploy_user}* failed to deploy branch `#{fetch :branch}` of `#{fetch :application}` to `#{fetch :rails_env, 'production'}`"

Emojis aside, it creates a nice output for the user, branch, repo, and environment.

screen shot 2015-09-16 at 2 28 52 pm

Not a real issue but thought I'd share :cocktail:

phallstrom commented 9 years ago

I like it. Not sure I'll change it unless other folks chime in, but I may well add it to the readme.

bradgreens commented 9 years ago

Sweet. I should note that it seems I needed to add set :rails_env, fetch(:stage) to my deploy.rb, it wasn't straightforward why adding the extra style was affecting that but it seemed to resolve a problem where :rails_env was getting lost.

seankibler commented 8 years ago

Maybe there is a place for a few different settings of out-of-the-box formatting. Say, set :slack_msg_format, :simple # :pretty, :fun with :simple being default. Instead of railroading the current defaults.

@bradgreens if you want to come up with some good formats for those or make some up I'll shoulder the implementation. No promises on timeline though. :) Also I invite @phallstrom to give a yay or nay before we put in any effort.

phallstrom commented 8 years ago

I'd be open to several defaults. Mostly though I don't want it to become a "war" in terms of what :pretty should mean, but if we can find some sensible defaults, I'm open to that. Why don't we start with the formats themselves (both JSON payload and screenshot). I need to refactor some other stuff anyway so am not opposed to making the rest work.

phallstrom commented 8 years ago

I'm currently rewriting things to support any and all formatting you want to spend the time implementing by letting you specify a "messaging class" that you then override whatever methods necessary to send what you want. Not quite done, but it Mostly Works™ right now. See the overhaul branch.

My thought is if folks come up with interesting/useful classes we can throw them and a screenshot into an examples directory, for others to re-use.

bradgreens commented 8 years ago

Thank you, we appreciate it!

phallstrom commented 8 years ago

If you're able, try using the overhaul branch without making any other changes and run cap production slack:deploy:test (or any other environment really) to see if your messaging continues to come through okay.

And or any other feedback you might have on that branch is appreciated.

bradgreens commented 8 years ago

I'll check it out, some of our crew will probably have feedback too. Will take a few days but now I'm just curious ;-)

phallstrom commented 8 years ago

And the trap has been set! :)

My configs work as is, but I haven't done some of the crazier things other folks have done. Theoretically it should work!

phallstrom commented 8 years ago

@bradgreens 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