slackistrano 0.1.12 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +53 -27
- data/lib/slackistrano/tasks/slack.rake +114 -42
- data/lib/slackistrano/version.rb +1 -1
- data/spec/capistrano_deploy_stubs.rake +6 -2
- data/spec/spec_helper.rb +2 -0
- data/spec/tasks_spec.rb +31 -19
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2221a5e8c65f2a1a082d139cc9cdaf7bb266285
|
4
|
+
data.tar.gz: f6b272f31ed0920fb37c1df17830c2908b7f3631
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d128baa0d6b1605117c0f9fa5ead20d8b306b28672e5efb10fc7a6df6a672c47d1a7b449967960b373e7e417c673e25e83eed23af6e5147070ab3457aff350a
|
7
|
+
data.tar.gz: 7e696369664825849d4908e8d90c20abb48541ecfcda1047d064f4e99238217de7bf9e0bcb0ef673717d455e0a20657ded8cac0f07516b14c888966215e02429
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Slackistrano Change Log
|
2
|
+
|
3
|
+
|
4
|
+
1.0.0
|
5
|
+
-----
|
6
|
+
|
7
|
+
- **BREAKING:** Renamed all `***_starting` settings to `***_updating`
|
8
|
+
- **BREAKING:** Renamed all `***_finished` settings to `***_updated`
|
9
|
+
- Added rollback options `***_reverting` and `***_reverted` [#19, #31]
|
10
|
+
|
data/README.md
CHANGED
@@ -58,32 +58,56 @@ set :slack_token, "xxxxxxxxxxxxxxxxxxxxxxxx"
|
|
58
58
|
set :slack_channel, '#general'
|
59
59
|
```
|
60
60
|
|
61
|
-
Optionally, override the other slack settings
|
61
|
+
Optionally, override the other slack settings.
|
62
62
|
|
63
63
|
```ruby
|
64
|
-
set :
|
65
|
-
set :
|
66
|
-
set :
|
67
|
-
set :
|
68
|
-
set :
|
69
|
-
|
70
|
-
set :
|
71
|
-
set :
|
72
|
-
set :
|
73
|
-
|
74
|
-
set :
|
75
|
-
set :
|
76
|
-
set :
|
77
|
-
set :
|
78
|
-
set :
|
79
|
-
|
80
|
-
set :
|
81
|
-
|
82
|
-
set :
|
83
|
-
set :
|
84
|
-
set :
|
85
|
-
set :
|
86
|
-
set :
|
64
|
+
set :slack_channel_updating, -> { nil } # Channel to post to. Defaults to :slack_channel.
|
65
|
+
set :slack_channel_reverting, -> { nil } # Channel to post to. Defaults to :slack_channel.
|
66
|
+
set :slack_channel_updated, -> { nil } # Channel to post to. Defaults to :slack_channel.
|
67
|
+
set :slack_channel_reverted, -> { nil } # Channel to post to. Defaults to :slack_channel.
|
68
|
+
set :slack_channel_failed, -> { nil } # Channel to post to. Defaults to :slack_channel.
|
69
|
+
|
70
|
+
set :slack_icon_url, -> { 'http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40' }
|
71
|
+
set :slack_icon_emoji, -> { nil } # Emoji to use. Overrides icon_url. Must be a string (ex: ':shipit:')
|
72
|
+
set :slack_username, -> { 'Slackistrano' }
|
73
|
+
|
74
|
+
set :slack_run_updating, -> { true } # Set to false to disable deploy starting message.
|
75
|
+
set :slack_run_reverting, -> { true } # Set to false to disable rollback starting message.
|
76
|
+
set :slack_run_updated, -> { true } # Set to false to disable deploy finished message.
|
77
|
+
set :slack_run_reverted, -> { true } # Set to false to disable rollback finished message.
|
78
|
+
set :slack_run_failed, -> { true } # Set to false to disable failure message.
|
79
|
+
|
80
|
+
set :slack_deploy_user, -> { ENV['USER'] || ENV['USERNAME'] }
|
81
|
+
|
82
|
+
set :slack_msg_updating, -> { "#{fetch :slack_deploy_user} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
83
|
+
set :slack_msg_reverting, -> { "#{fetch :slack_deploy_user} has started rolling back branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
84
|
+
set :slack_msg_updated, -> { "#{fetch :slack_deploy_user} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
85
|
+
set :slack_msg_reverted, -> { "#{fetch :slack_deploy_user} has finished rolling back branch of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
86
|
+
set :slack_msg_failed, -> { "#{fetch :slack_deploy_user} has failed to #{fetch :slack_deploy_or_rollback} branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
87
|
+
|
88
|
+
set :slack_fields_updating, -> { [] }
|
89
|
+
set :slack_fields_reverting, -> { [] }
|
90
|
+
set :slack_fields_updated, -> { [] }
|
91
|
+
set :slack_fields_reverted, -> { [] }
|
92
|
+
set :slack_fields_failed, -> { [] }
|
93
|
+
|
94
|
+
set :slack_fallback_updating, -> { nil }
|
95
|
+
set :slack_fallback_reverting, -> { nil }
|
96
|
+
set :slack_fallback_updated, -> { nil }
|
97
|
+
set :slack_fallback_reverted, -> { nil }
|
98
|
+
set :slack_fallback_failed, -> { nil }
|
99
|
+
|
100
|
+
set :slack_title_updating, -> { nil }
|
101
|
+
set :slack_title_reverting, -> { nil }
|
102
|
+
set :slack_title_updated, -> { nil }
|
103
|
+
set :slack_title_reverted, -> { nil }
|
104
|
+
set :slack_title_failed, -> { nil }
|
105
|
+
|
106
|
+
set :slack_pretext_updating, -> { nil }
|
107
|
+
set :slack_pretext_reverting, -> { nil }
|
108
|
+
set :slack_pretext_updated, -> { nil }
|
109
|
+
set :slack_pretext_reverted, -> { nil }
|
110
|
+
set :slack_pretext_failed, -> { nil }
|
87
111
|
```
|
88
112
|
|
89
113
|
**Note**: You may wish to disable one of the notifications if another service (ex:
|
@@ -92,8 +116,10 @@ Honeybadger) also displays a deploy notification.
|
|
92
116
|
Test your setup by running:
|
93
117
|
|
94
118
|
```bash
|
95
|
-
$ cap production slack:deploy:
|
96
|
-
$ cap production slack:deploy:
|
119
|
+
$ cap production slack:deploy:updating
|
120
|
+
$ cap production slack:deploy:reverting
|
121
|
+
$ cap production slack:deploy:updated
|
122
|
+
$ cap production slack:deploy:reverted
|
97
123
|
$ cap production slack:deploy:failed
|
98
124
|
```
|
99
125
|
|
@@ -135,7 +161,7 @@ It will produce the following format:
|
|
135
161
|
|
136
162
|
**Note 1:** *The `fallback` field is required in order to display notifications when using `fields`.*
|
137
163
|
|
138
|
-
**Note 2:** *The `fields`
|
164
|
+
**Note 2:** *The `fields` configuration requires you to use webhooks.*
|
139
165
|
|
140
166
|
More information: [https://api.slack.com/docs/attachments](https://api.slack.com/docs/attachments)
|
141
167
|
|
@@ -12,8 +12,9 @@ namespace :slack do
|
|
12
12
|
[attachments]
|
13
13
|
end
|
14
14
|
|
15
|
-
task :
|
16
|
-
|
15
|
+
task :updating do
|
16
|
+
set(:slack_deploy_or_rollback, 'deploy')
|
17
|
+
if fetch(:slack_run_updating)
|
17
18
|
run_locally do
|
18
19
|
Slackistrano.post(
|
19
20
|
team: fetch(:slack_team),
|
@@ -21,19 +22,20 @@ namespace :slack do
|
|
21
22
|
webhook: fetch(:slack_webhook),
|
22
23
|
via_slackbot: fetch(:slack_via_slackbot),
|
23
24
|
payload: {
|
24
|
-
channel: fetch(:
|
25
|
+
channel: fetch(:slack_channel_updating) || fetch(:slack_channel),
|
25
26
|
username: fetch(:slack_username),
|
26
27
|
icon_url: fetch(:slack_icon_url),
|
27
28
|
icon_emoji: fetch(:slack_icon_emoji),
|
28
|
-
attachments: make_attachments(:
|
29
|
+
attachments: make_attachments(:updating)
|
29
30
|
}
|
30
31
|
)
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
task :
|
36
|
-
|
36
|
+
task :reverting do
|
37
|
+
set(:slack_deploy_or_rollback, 'rollback')
|
38
|
+
if fetch(:slack_run_reverting)
|
37
39
|
run_locally do
|
38
40
|
Slackistrano.post(
|
39
41
|
team: fetch(:slack_team),
|
@@ -41,11 +43,52 @@ namespace :slack do
|
|
41
43
|
webhook: fetch(:slack_webhook),
|
42
44
|
via_slackbot: fetch(:slack_via_slackbot),
|
43
45
|
payload: {
|
44
|
-
channel: fetch(:
|
46
|
+
channel: fetch(:slack_channel_reverting) || fetch(:slack_channel),
|
45
47
|
username: fetch(:slack_username),
|
46
48
|
icon_url: fetch(:slack_icon_url),
|
47
49
|
icon_emoji: fetch(:slack_icon_emoji),
|
48
|
-
attachments: make_attachments(:
|
50
|
+
attachments: make_attachments(:reverting)
|
51
|
+
}
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
task :updated do
|
59
|
+
if fetch(:slack_run_updated)
|
60
|
+
run_locally do
|
61
|
+
Slackistrano.post(
|
62
|
+
team: fetch(:slack_team),
|
63
|
+
token: fetch(:slack_token),
|
64
|
+
webhook: fetch(:slack_webhook),
|
65
|
+
via_slackbot: fetch(:slack_via_slackbot),
|
66
|
+
payload: {
|
67
|
+
channel: fetch(:slack_channel_updated) || fetch(:slack_channel),
|
68
|
+
username: fetch(:slack_username),
|
69
|
+
icon_url: fetch(:slack_icon_url),
|
70
|
+
icon_emoji: fetch(:slack_icon_emoji),
|
71
|
+
attachments: make_attachments(:updated, color: 'good')
|
72
|
+
}
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
task :reverted do
|
79
|
+
if fetch(:slack_run_reverted)
|
80
|
+
run_locally do
|
81
|
+
Slackistrano.post(
|
82
|
+
team: fetch(:slack_team),
|
83
|
+
token: fetch(:slack_token),
|
84
|
+
webhook: fetch(:slack_webhook),
|
85
|
+
via_slackbot: fetch(:slack_via_slackbot),
|
86
|
+
payload: {
|
87
|
+
channel: fetch(:slack_channel_reverted) || fetch(:slack_channel),
|
88
|
+
username: fetch(:slack_username),
|
89
|
+
icon_url: fetch(:slack_icon_url),
|
90
|
+
icon_emoji: fetch(:slack_icon_emoji),
|
91
|
+
attachments: make_attachments(:reverted, color: '#4CBDEC')
|
49
92
|
}
|
50
93
|
)
|
51
94
|
end
|
@@ -75,43 +118,72 @@ namespace :slack do
|
|
75
118
|
end
|
76
119
|
end
|
77
120
|
|
78
|
-
|
79
|
-
|
80
|
-
after
|
121
|
+
before 'deploy:updating', 'slack:deploy:updating'
|
122
|
+
before 'deploy:reverting', 'slack:deploy:reverting'
|
123
|
+
after 'deploy:finishing', 'slack:deploy:updated'
|
124
|
+
after 'deploy:finishing_rollback', 'slack:deploy:reverted'
|
125
|
+
after 'deploy:failed', 'slack:deploy:failed'
|
81
126
|
|
82
127
|
namespace :load do
|
83
128
|
task :defaults do
|
84
129
|
|
85
|
-
set :slack_team,
|
86
|
-
set :slack_token,
|
87
|
-
set :slack_webhook,
|
88
|
-
set :slack_via_slackbot,
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
set :
|
94
|
-
set :
|
95
|
-
set :
|
96
|
-
set :
|
97
|
-
set :
|
98
|
-
|
99
|
-
set :
|
100
|
-
set :
|
101
|
-
set :
|
102
|
-
|
103
|
-
set :
|
104
|
-
set :
|
105
|
-
set :
|
106
|
-
set :
|
107
|
-
set :
|
108
|
-
|
109
|
-
set :
|
110
|
-
|
111
|
-
set :
|
112
|
-
set :
|
113
|
-
set :
|
114
|
-
set :
|
115
|
-
|
130
|
+
set :slack_team, -> { nil } # If URL is 'team.slack.com', value is 'team'.
|
131
|
+
set :slack_token, -> { nil } # Token from Incoming WebHooks.
|
132
|
+
set :slack_webhook, -> { nil } # Incoming WebHook URL.
|
133
|
+
set :slack_via_slackbot, -> { false } # Set to true to send the message via slackbot instead of webhook
|
134
|
+
set :slack_channel, -> { nil } # Channel to post to. Optional. Defaults to WebHook setting.
|
135
|
+
|
136
|
+
# Optional, overridable settings
|
137
|
+
|
138
|
+
set :slack_channel_updating, -> { nil } # Channel to post to. Defaults to :slack_channel.
|
139
|
+
set :slack_channel_reverting, -> { nil } # Channel to post to. Defaults to :slack_channel.
|
140
|
+
set :slack_channel_updated, -> { nil } # Channel to post to. Defaults to :slack_channel.
|
141
|
+
set :slack_channel_reverted, -> { nil } # Channel to post to. Defaults to :slack_channel.
|
142
|
+
set :slack_channel_failed, -> { nil } # Channel to post to. Defaults to :slack_channel.
|
143
|
+
|
144
|
+
set :slack_icon_url, -> { 'http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40' }
|
145
|
+
set :slack_icon_emoji, -> { nil } # Emoji to use. Overrides icon_url. Must be a string (ex: ':shipit:')
|
146
|
+
set :slack_username, -> { 'Slackistrano' }
|
147
|
+
|
148
|
+
set :slack_run_updating, -> { true } # Set to false to disable deploy starting message.
|
149
|
+
set :slack_run_reverting, -> { true } # Set to false to disable rollback starting message.
|
150
|
+
set :slack_run_updated, -> { true } # Set to false to disable deploy finished message.
|
151
|
+
set :slack_run_reverted, -> { true } # Set to false to disable rollback finished message.
|
152
|
+
set :slack_run_failed, -> { true } # Set to false to disable failure message.
|
153
|
+
|
154
|
+
set :slack_deploy_user, -> { ENV['USER'] || ENV['USERNAME'] }
|
155
|
+
|
156
|
+
set :slack_msg_updating, -> { "#{fetch :slack_deploy_user} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
157
|
+
set :slack_msg_reverting, -> { "#{fetch :slack_deploy_user} has started rolling back branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
158
|
+
set :slack_msg_updated, -> { "#{fetch :slack_deploy_user} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
159
|
+
set :slack_msg_reverted, -> { "#{fetch :slack_deploy_user} has finished rolling back branch of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
160
|
+
|
161
|
+
# :slack_or_deploy is set in several tasks above.
|
162
|
+
set :slack_msg_failed, -> { "#{fetch :slack_deploy_user} has failed to #{fetch(:slack_deploy_or_rollback) || 'deploy'} branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
163
|
+
|
164
|
+
set :slack_fields_updating, -> { [] }
|
165
|
+
set :slack_fields_reverting, -> { [] }
|
166
|
+
set :slack_fields_updated, -> { [] }
|
167
|
+
set :slack_fields_reverted, -> { [] }
|
168
|
+
set :slack_fields_failed, -> { [] }
|
169
|
+
|
170
|
+
set :slack_fallback_updating, -> { nil }
|
171
|
+
set :slack_fallback_reverting, -> { nil }
|
172
|
+
set :slack_fallback_updated, -> { nil }
|
173
|
+
set :slack_fallback_reverted, -> { nil }
|
174
|
+
set :slack_fallback_failed, -> { nil }
|
175
|
+
|
176
|
+
set :slack_title_updating, -> { nil }
|
177
|
+
set :slack_title_reverting, -> { nil }
|
178
|
+
set :slack_title_updated, -> { nil }
|
179
|
+
set :slack_title_reverted, -> { nil }
|
180
|
+
set :slack_title_failed, -> { nil }
|
181
|
+
|
182
|
+
set :slack_pretext_updating, -> { nil }
|
183
|
+
set :slack_pretext_reverting, -> { nil }
|
184
|
+
set :slack_pretext_updated, -> { nil }
|
185
|
+
set :slack_pretext_reverted, -> { nil }
|
186
|
+
set :slack_pretext_failed, -> { nil }
|
187
|
+
|
116
188
|
end
|
117
189
|
end
|
data/lib/slackistrano/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/tasks_spec.rb
CHANGED
@@ -5,25 +5,34 @@ describe Slackistrano do
|
|
5
5
|
Rake::Task['load:defaults'].invoke
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
set :slack_run_starting, ->{ true }
|
10
|
-
expect(Slackistrano).to receive :post
|
11
|
-
Rake::Task['deploy:starting'].execute
|
12
|
-
end
|
8
|
+
describe "before/after hooks" do
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
it "invokes slack:deploy:updating before deploy:updating" do
|
11
|
+
expect(Rake::Task['deploy:updating'].prerequisites).to include 'slack:deploy:updating'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "invokes slack:deploy:reverting before deploy:reverting" do
|
15
|
+
expect(Rake::Task['deploy:reverting'].prerequisites).to include 'slack:deploy:reverting'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "invokes slack:deploy:updated after deploy:finishing" do
|
19
|
+
expect(Rake::Task['slack:deploy:updated']).to receive(:invoke)
|
20
|
+
Rake::Task['deploy:finishing'].execute
|
21
|
+
end
|
22
|
+
|
23
|
+
it "invokes slack:deploy:reverted after deploy:finishing_rollback" do
|
24
|
+
expect(Rake::Task['slack:deploy:reverted']).to receive(:invoke)
|
25
|
+
Rake::Task['deploy:finishing_rollback'].execute
|
26
|
+
end
|
27
|
+
|
28
|
+
it "invokes slack:deploy:failed after deploy:failed" do
|
29
|
+
expect(Rake::Task['slack:deploy:failed']).to receive(:invoke)
|
30
|
+
Rake::Task['deploy:failed'].execute
|
31
|
+
end
|
19
32
|
|
20
|
-
it "invokes slack:deploy:failed after deploy:failed" do
|
21
|
-
set :slack_run_failed, ->{ true }
|
22
|
-
expect(Slackistrano).to receive :post
|
23
|
-
Rake::Task['deploy:failed'].execute
|
24
33
|
end
|
25
34
|
|
26
|
-
%w[
|
35
|
+
%w[updating reverting updated reverted failed].each do |stage|
|
27
36
|
it "posts to slack on slack:deploy:#{stage}" do
|
28
37
|
set "slack_run_#{stage}".to_sym, ->{ true }
|
29
38
|
expect(Slackistrano).to receive :post
|
@@ -38,11 +47,14 @@ describe Slackistrano do
|
|
38
47
|
end
|
39
48
|
|
40
49
|
[ # stage, color, channel
|
41
|
-
['
|
42
|
-
['
|
50
|
+
['updating', nil, nil],
|
51
|
+
['reverting', nil, nil],
|
52
|
+
['updated', 'good', nil],
|
53
|
+
['reverted', '#4CBDEC', nil],
|
43
54
|
['failed', 'danger', nil],
|
44
|
-
['
|
45
|
-
['
|
55
|
+
['updating', nil, 'starting_channel'],
|
56
|
+
['updated', 'good', 'finished_channel'],
|
57
|
+
['reverted', '#4CBDEC', 'rollback_channel'],
|
46
58
|
['failed', 'danger', 'failed_channel'],
|
47
59
|
].each do |stage, color, channel_for_stage|
|
48
60
|
|
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.
|
4
|
+
version: 1.0.0
|
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-
|
11
|
+
date: 2015-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
77
|
- ".travis.yml"
|
78
|
+
- CHANGELOG.md
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|