slackistrano 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -10
- data/lib/slackistrano/tasks/slack.rake +16 -13
- data/lib/slackistrano/version.rb +1 -1
- data/spec/tasks_spec.rb +25 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c46fe6f2630d18ead53c0c8ca36b86aabd0edb90
|
4
|
+
data.tar.gz: f69b3b353ef735704a1b48d4af51bcb277a18e32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eda0cdd9fa315bc4d20e05e4552a8276347f95c18951defe03f46b56636bdd86ff66853a2b8af3bd506da16b02805ecd11e3145ef690afd7fddc67fa2cb2d336
|
7
|
+
data.tar.gz: 2971b27195aff30bc885ee8d6b3abd09d73677c948de6387c9ec7a9d250f26b9d042e90ae789c979dd1c534664f5167043258d3560bf458382303e1f1f264995
|
data/README.md
CHANGED
@@ -51,16 +51,19 @@ If you choose to post using *Slackbot* you **must** set your team and and token
|
|
51
51
|
|
52
52
|
Optionally, override the other slack settings:
|
53
53
|
|
54
|
-
set :slack_icon_url,
|
55
|
-
set :slack_icon_emoji,
|
56
|
-
set :slack_channel,
|
57
|
-
set :
|
58
|
-
set :
|
59
|
-
set :
|
60
|
-
set :
|
61
|
-
set :
|
62
|
-
set :
|
63
|
-
set :
|
54
|
+
set :slack_icon_url, -> { 'http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40' }
|
55
|
+
set :slack_icon_emoji, -> { nil } # will override icon_url, Must be a string (ex: ':shipit:')
|
56
|
+
set :slack_channel, -> { '#general' }
|
57
|
+
set :slack_channel_starting, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
58
|
+
set :slack_channel_finished, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
59
|
+
set :slack_channel_failed, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
60
|
+
set :slack_username, -> { 'Slackistrano' }
|
61
|
+
set :slack_run_starting, -> { true }
|
62
|
+
set :slack_run_finished, -> { true }
|
63
|
+
set :slack_run_failed, -> { true }
|
64
|
+
set :slack_msg_starting, -> { "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
|
65
|
+
set :slack_msg_finished, -> { "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
|
66
|
+
set :slack_msg_failed, -> { "#{ENV['USER'] || ENV['USERNAME']} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
|
64
67
|
|
65
68
|
**Note**: You may wish to disable one of the notifications if another service (ex:
|
66
69
|
Honeybadger) also displays a deploy notification.
|
@@ -11,7 +11,7 @@ namespace :slack do
|
|
11
11
|
webhook: fetch(:slack_webhook),
|
12
12
|
via_slackbot: fetch(:slack_via_slackbot),
|
13
13
|
payload: {
|
14
|
-
channel: fetch(:slack_channel),
|
14
|
+
channel: fetch(:slack_channel_starting) || fetch(:slack_channel),
|
15
15
|
username: fetch(:slack_username),
|
16
16
|
icon_url: fetch(:slack_icon_url),
|
17
17
|
icon_emoji: fetch(:slack_icon_emoji),
|
@@ -33,7 +33,7 @@ namespace :slack do
|
|
33
33
|
webhook: fetch(:slack_webhook),
|
34
34
|
via_slackbot: fetch(:slack_via_slackbot),
|
35
35
|
payload: {
|
36
|
-
channel: fetch(:slack_channel),
|
36
|
+
channel: fetch(:slack_channel_finished) || fetch(:slack_channel),
|
37
37
|
username: fetch(:slack_username),
|
38
38
|
icon_url: fetch(:slack_icon_url),
|
39
39
|
icon_emoji: fetch(:slack_icon_emoji),
|
@@ -56,7 +56,7 @@ namespace :slack do
|
|
56
56
|
webhook: fetch(:slack_webhook),
|
57
57
|
via_slackbot: fetch(:slack_via_slackbot),
|
58
58
|
payload: {
|
59
|
-
channel: fetch(:slack_channel),
|
59
|
+
channel: fetch(:slack_channel_failed) || fetch(:slack_channel),
|
60
60
|
username: fetch(:slack_username),
|
61
61
|
icon_url: fetch(:slack_icon_url),
|
62
62
|
icon_emoji: fetch(:slack_icon_emoji),
|
@@ -85,15 +85,18 @@ namespace :load do
|
|
85
85
|
set :slack_webhook, ->{ nil } # Incoming WebHook URL.
|
86
86
|
set :slack_via_slackbot, ->{ false } # Set to true to send the message via slackbot instead of webhook
|
87
87
|
|
88
|
-
set :slack_channel,
|
89
|
-
set :
|
90
|
-
set :
|
91
|
-
set :
|
92
|
-
set :
|
93
|
-
set :
|
94
|
-
set :
|
95
|
-
set :
|
96
|
-
set :
|
97
|
-
set :
|
88
|
+
set :slack_channel, -> { nil } # Channel to post to. Optional. Defaults to WebHook setting.
|
89
|
+
set :slack_channel_starting, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
90
|
+
set :slack_channel_finished, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
91
|
+
set :slack_channel_failed, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
92
|
+
set :slack_icon_url, -> { 'http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40' }
|
93
|
+
set :slack_icon_emoji, -> { nil } # Emoji to use. Overrides icon_url. Must be a string (ex: ':shipit:')
|
94
|
+
set :slack_username, -> { 'Slackistrano' }
|
95
|
+
set :slack_run_starting, -> { true } # Set to false to disable starting message.
|
96
|
+
set :slack_run_finished, -> { true } # Set to false to disable finished message.
|
97
|
+
set :slack_run_failed, -> { true } # Set to false to disable failure message.
|
98
|
+
set :slack_msg_starting, -> { "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
99
|
+
set :slack_msg_finished, -> { "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
100
|
+
set :slack_msg_failed, -> { "#{ENV['USER'] || ENV['USERNAME']} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
98
101
|
end
|
99
102
|
end
|
data/lib/slackistrano/version.rb
CHANGED
data/spec/tasks_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe Slackistrano do
|
|
23
23
|
Rake::Task['deploy:failed'].execute
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
%w[starting finished failed].each do |stage|
|
27
27
|
it "posts to slack on slack:deploy:#{stage}" do
|
28
28
|
set "slack_run_#{stage}".to_sym, ->{ true }
|
29
29
|
expect(Slackistrano).to receive :post
|
@@ -35,19 +35,31 @@ describe Slackistrano do
|
|
35
35
|
expect(Slackistrano).not_to receive :post
|
36
36
|
Rake::Task["slack:deploy:#{stage}"].execute
|
37
37
|
end
|
38
|
+
end
|
39
|
+
|
40
|
+
[ # stage, color, channel
|
41
|
+
['starting', nil, nil],
|
42
|
+
['finished', 'good', nil],
|
43
|
+
['failed', 'danger', nil],
|
44
|
+
['starting', nil, 'starting_channel'],
|
45
|
+
['finished', 'good', 'finished_channel'],
|
46
|
+
['failed', 'danger', 'failed_channel'],
|
47
|
+
].each do |stage, color, channel_for_stage|
|
48
|
+
|
49
|
+
it "calls Slackistrano.post with the right arguments for stage=#{stage}, color=#{color}, channel_for_stage=#{channel_for_stage}" do
|
50
|
+
set :"slack_run_#{stage}", -> { true }
|
51
|
+
set :slack_team, -> { 'team' }
|
52
|
+
set :slack_token, -> { 'token' }
|
53
|
+
set :slack_webhook, -> { 'webhook' }
|
54
|
+
set :slack_channel, -> { 'channel' }
|
55
|
+
set :slack_icon_url, -> { 'http://icon.url' }
|
56
|
+
set :slack_icon_emoji, -> { ':emoji:' }
|
57
|
+
set :"slack_msg_#{stage}", -> { 'text message' }
|
38
58
|
|
39
|
-
|
40
|
-
|
41
|
-
set :slack_team, ->{ 'team' }
|
42
|
-
set :slack_token, ->{ 'token' }
|
43
|
-
set :slack_webhook, ->{ 'webhook' }
|
44
|
-
set :slack_channel, ->{ 'channel' }
|
45
|
-
set :slack_icon_url, ->{ 'http://icon.url' }
|
46
|
-
set :slack_icon_emoji, ->{ ':emoji:' }
|
47
|
-
set :"slack_msg_#{stage}", ->{ 'text message' }
|
59
|
+
set :"slack_channel_#{stage}", -> { channel_for_stage }
|
60
|
+
expected_channel = channel_for_stage || 'channel'
|
48
61
|
|
49
|
-
attachment = {text: 'text message'}
|
50
|
-
attachment[:color] = color unless color.nil?
|
62
|
+
attachment = {text: 'text message', color: color}.reject{|k,v| v.nil?}
|
51
63
|
|
52
64
|
expect(Slackistrano).to receive(:post).with(
|
53
65
|
team: 'team',
|
@@ -55,7 +67,7 @@ describe Slackistrano do
|
|
55
67
|
webhook: 'webhook',
|
56
68
|
via_slackbot: false,
|
57
69
|
payload: {
|
58
|
-
channel:
|
70
|
+
channel: expected_channel,
|
59
71
|
username: 'Slackistrano',
|
60
72
|
icon_url: 'http://icon.url',
|
61
73
|
icon_emoji: ':emoji:',
|
@@ -66,15 +78,5 @@ describe Slackistrano do
|
|
66
78
|
end
|
67
79
|
end
|
68
80
|
|
69
|
-
describe 'build is starting' do
|
70
|
-
it_should_behave_like "slack notification", :starting
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'build has finished' do
|
74
|
-
it_should_behave_like "slack notification", :finished, 'good'
|
75
|
-
end
|
76
81
|
|
77
|
-
describe 'build has failed' do
|
78
|
-
it_should_behave_like "slack notification", :failed, 'danger'
|
79
|
-
end
|
80
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slackistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Hallstrom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|