lib/slackistrano/tasks/slack.rake in slackistrano-0.0.4 vs lib/slackistrano/tasks/slack.rake in slackistrano-0.0.5
- old
+ new
@@ -1,36 +1,42 @@
+
namespace :slack do
namespace :deploy do
+
task :starting do
- run_locally do
- text = "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'unknown stage'}."
- Slackistrano.post(
- team: fetch(:slack_team),
- token: fetch(:slack_token),
- payload: {
- channel: fetch(:slack_channel),
- username: fetch(:slack_username),
- icon_url: fetch(:slack_icon_url),
- text: text
- }
- )
+ if fetch(:slack_run_starting)
+ run_locally do
+ text = "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}."
+ Slackistrano.post(
+ team: fetch(:slack_team),
+ token: fetch(:slack_token),
+ payload: {
+ channel: fetch(:slack_channel),
+ username: fetch(:slack_username),
+ icon_url: fetch(:slack_icon_url),
+ text: text
+ }
+ )
+ end
end
end
task :finished do
- run_locally do
- text = "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'unknown stage'}."
- Slackistrano.post(
- team: fetch(:slack_team),
- token: fetch(:slack_token),
- payload: {
- channel: fetch(:slack_channel),
- username: fetch(:slack_username),
- icon_url: fetch(:slack_icon_url),
- text: text
- }
- )
+ if fetch(:slack_run_finished)
+ run_locally do
+ text = "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}."
+ Slackistrano.post(
+ team: fetch(:slack_team),
+ token: fetch(:slack_token),
+ payload: {
+ channel: fetch(:slack_channel),
+ username: fetch(:slack_username),
+ icon_url: fetch(:slack_icon_url),
+ text: text
+ }
+ )
+ end
end
end
end
end
@@ -39,10 +45,12 @@
namespace :load do
task :defaults do
set :slack_team, ->{ nil } # If URL is 'team.slack.com', value is 'team'. Required.
set :slack_token, ->{ nil } # Token from Incoming WebHooks. Required.
- set :slack_icon_url, ->{ "http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40" }
- set :slack_channel, ->{ "#general" }
- set :slack_username, ->{ "Slackistrano" }
+ set :slack_icon_url, ->{ 'http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40' }
+ set :slack_channel, ->{ '#general' }
+ set :slack_username, ->{ 'Slackistrano' }
+ set :slack_run_starting, ->{ true } # Set to false to disable starting message.
+ set :slack_run_finished, ->{ true } # Set to false to disable finished message.
end
end