phallstrom / slackistrano

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

Add support for specific environments to trigger notifications #35

Closed galenandrew closed 8 years ago

galenandrew commented 8 years ago

It would be awesome to have a variable (array) of environments that trigger slack notifications vs copying the same notification settings into each environment's deploy script.

This would allow for the notification settings to live globally in config/deploy.rb yet only the defined environments would trigger notifications.

Example: We do a lot of deployments to development and don't necessarily want to clutter our slack channel with notifications from those deployments however we do want notifications for all staging and production deployments.

Setting an array variable (e.g. :slack_environments) would allow for a cleaner/dry-er config.

phallstrom commented 8 years ago

@galenandrew Couldn't you put everything into config/deploy.rb and then put the following into config/deploy/development.rb:

set :slack_run_updating,       -> { false }
set :slack_run_reverting,      -> { false }
set :slack_run_updated,        -> { false }
set :slack_run_reverted,       -> { false }
set :slack_run_failed,         -> { false }

Or am I misunderstanding?

galenandrew commented 8 years ago

Thanks for the alternative approach @phallstrom!! That is definitely an approach that will accomplish only sending notifications for specific environments, but it still requires duplicating the same code to across multiple files "disable" the notifications.

My thought behind opening this was more of an enhancement idea vs an issue/bug. I was thinking it could be a simple whitelist for environments by setting set :slack_stages, %w(production staging). Maybe in addition to this it also honors the options you've listed?

I'm not a ruby developer, but would be up for taking a stab at a pull request. Any guidance or pointers on where this would make sense is appreciated.

mikz commented 8 years ago

It would be much nicer to have a slack_enabled variable and in the correct stage file disable it.

Adding simple early return to the https://github.com/phallstrom/slackistrano/blob/78b9201f5ad59075cc27c744d52f1ea82c042878/lib/slackistrano/tasks/slack.rake#L38 should do it.

phallstrom commented 8 years ago

@mikz I like that. Soon.

phallstrom commented 8 years ago

This will soon be available as 2.0.1 on rubygems.

mikz commented 8 years ago

:+1: :star:

galenandrew commented 8 years ago

:metal: this solution is great!! Thanks @phallstrom and @mikz!