slackistrano 3.8.1 → 3.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +97 -72
- data/lib/slackistrano/messaging/base.rb +10 -8
- data/lib/slackistrano/messaging/helpers.rb +3 -3
- data/lib/slackistrano/version.rb +1 -1
- data/spec/messaging/helpers_spec.rb +33 -0
- 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: 4fac68f58cb93ece5bc58a404e97e1e21189d841
|
4
|
+
data.tar.gz: b58e73827ae619e20a4e2a61081872177c810ac4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34024139c2b12d28ddcf69428009078d931621ed75018d2c5c448464da14b6291aff0ec6193cc803bbac701c0a34b49ef977100e925d0298a26909f6b7260714
|
7
|
+
data.tar.gz: 5259c193fe28f066d04972abbe22345295b9ccd8f3a305a9426c26e539c911d5ebc7723ed28221e430f136fe45e767fe6408426391d20ddbbeba1d9b1ceea605
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -66,6 +66,26 @@ You have two options to notify a channel in Slack when you deploy:
|
|
66
66
|
}
|
67
67
|
```
|
68
68
|
|
69
|
+
### Optional Configuration & Overrides
|
70
|
+
|
71
|
+
By default Slackistrano will use a default icon and username. These, can be
|
72
|
+
overriden if you are using the default messaging class (ie. have not specified
|
73
|
+
your own).
|
74
|
+
|
75
|
+
1. Configure per instructions above.
|
76
|
+
2. Add the following to `config/deploy.rb`:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
set :slackistrano, {
|
80
|
+
...
|
81
|
+
username: 'Foobar the Deployer',
|
82
|
+
icon_emoji: ':thumbsup:', # takes precedence over icon_url
|
83
|
+
icon_url: 'https://avatars2.githubusercontent.com/u/16705?v=4&s=40',
|
84
|
+
...
|
85
|
+
}
|
86
|
+
```
|
87
|
+
|
88
|
+
|
69
89
|
### Test your Configuration
|
70
90
|
|
71
91
|
Test your setup by running the following command. This will post each stage's
|
@@ -86,78 +106,83 @@ You can customize the messaging posted to Slack by providing your own messaging
|
|
86
106
|
class and overriding several methods. Here is one example:
|
87
107
|
|
88
108
|
```ruby
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
109
|
+
if defined?(Slackistrano::Messaging)
|
110
|
+
module Slackistrano
|
111
|
+
class CustomMessaging < Messaging::Base
|
112
|
+
|
113
|
+
# Send failed message to #ops. Send all other messages to default channels.
|
114
|
+
# The #ops channel must exist prior.
|
115
|
+
def channels_for(action)
|
116
|
+
if action == :failed
|
117
|
+
"#ops"
|
118
|
+
else
|
119
|
+
super
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# Suppress updating message.
|
124
|
+
def payload_for_updating
|
125
|
+
nil
|
126
|
+
end
|
127
|
+
|
128
|
+
# Suppress reverting message.
|
129
|
+
def payload_for_reverting
|
130
|
+
nil
|
131
|
+
end
|
132
|
+
|
133
|
+
# Fancy updated message.
|
134
|
+
# See https://api.slack.com/docs/message-attachments
|
135
|
+
def payload_for_updated
|
136
|
+
{
|
137
|
+
attachments: [{
|
138
|
+
color: 'good',
|
139
|
+
title: 'Integrations Application Deployed :boom::bangbang:',
|
140
|
+
fields: [{
|
141
|
+
title: 'Environment',
|
142
|
+
value: stage,
|
143
|
+
short: true
|
144
|
+
}, {
|
145
|
+
title: 'Branch',
|
146
|
+
value: branch,
|
147
|
+
short: true
|
148
|
+
}, {
|
149
|
+
title: 'Deployer',
|
150
|
+
value: deployer,
|
151
|
+
short: true
|
152
|
+
}, {
|
153
|
+
title: 'Time',
|
154
|
+
value: elapsed_time,
|
155
|
+
short: true
|
156
|
+
}],
|
157
|
+
fallback: super[:text]
|
158
|
+
}]
|
159
|
+
}
|
160
|
+
end
|
161
|
+
|
162
|
+
# Default reverted message. Alternatively simply do not redefine this
|
163
|
+
# method.
|
164
|
+
def payload_for_reverted
|
165
|
+
super
|
166
|
+
end
|
167
|
+
|
168
|
+
# Slightly tweaked failed message.
|
169
|
+
# See https://api.slack.com/docs/message-formatting
|
170
|
+
def payload_for_failed
|
171
|
+
payload = super
|
172
|
+
payload[:text] = "OMG :fire: #{payload[:text]}"
|
173
|
+
payload
|
174
|
+
end
|
175
|
+
|
176
|
+
# Override the deployer helper to pull the best name available (git, password file, env vars).
|
177
|
+
# See https://github.com/phallstrom/slackistrano/blob/master/lib/slackistrano/messaging/helpers.rb
|
178
|
+
def deployer
|
179
|
+
name = `git config user.name`.strip
|
180
|
+
name = nil if name.empty?
|
181
|
+
name ||= Etc.getpwnam(ENV['USER']).gecos || ENV['USER'] || ENV['USERNAME']
|
182
|
+
name
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
161
186
|
end
|
162
187
|
```
|
163
188
|
|
@@ -10,14 +10,16 @@ module Slackistrano
|
|
10
10
|
extend Forwardable
|
11
11
|
def_delegators :env, :fetch
|
12
12
|
|
13
|
-
attr_reader :team, :token, :webhook
|
14
|
-
|
15
|
-
def initialize(
|
16
|
-
@
|
17
|
-
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
13
|
+
attr_reader :team, :token, :webhook, :options
|
14
|
+
|
15
|
+
def initialize(options = {})
|
16
|
+
@options = options.dup
|
17
|
+
|
18
|
+
@env = options.delete(:env)
|
19
|
+
@team = options.delete(:team)
|
20
|
+
@channel = options.delete(:channel)
|
21
|
+
@token = options.delete(:token)
|
22
|
+
@webhook = options.delete(:webhook)
|
21
23
|
end
|
22
24
|
|
23
25
|
def payload_for_updating
|
@@ -3,15 +3,15 @@ module Slackistrano
|
|
3
3
|
module Helpers
|
4
4
|
|
5
5
|
def icon_url
|
6
|
-
'https://raw.githubusercontent.com/phallstrom/slackistrano/master/images/slackistrano.png'
|
6
|
+
options.fetch(:icon_url, 'https://raw.githubusercontent.com/phallstrom/slackistrano/master/images/slackistrano.png')
|
7
7
|
end
|
8
8
|
|
9
9
|
def icon_emoji
|
10
|
-
nil
|
10
|
+
options.fetch(:icon_emoji, nil)
|
11
11
|
end
|
12
12
|
|
13
13
|
def username
|
14
|
-
'Slackistrano'
|
14
|
+
options.fetch(:username, 'Slackistrano')
|
15
15
|
end
|
16
16
|
|
17
17
|
def deployer
|
data/lib/slackistrano/version.rb
CHANGED
@@ -2,6 +2,39 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Slackistrano::Messaging::Default do
|
4
4
|
|
5
|
+
describe "#icon_url" do
|
6
|
+
it "returns a default" do
|
7
|
+
expect(subject.icon_url).to match(/phallstrom.*slackistrano.png/)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns a custom option" do
|
11
|
+
allow(subject).to receive(:options).and_return(icon_url: 'http://example.com/foo.png')
|
12
|
+
expect(subject.icon_url).to eq 'http://example.com/foo.png'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#icon_emoji" do
|
17
|
+
it "returns a default of nil" do
|
18
|
+
expect(subject.icon_emoji).to eq nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns a custom option" do
|
22
|
+
allow(subject).to receive(:options).and_return(icon_emoji: ':thumbsup:')
|
23
|
+
expect(subject.icon_emoji).to eq ':thumbsup:'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#username" do
|
28
|
+
it "returns a default" do
|
29
|
+
expect(subject.username).to eq 'Slackistrano'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns a custom option" do
|
33
|
+
allow(subject).to receive(:options).and_return(username: 'Codan the Deployer')
|
34
|
+
expect(subject.username).to eq 'Codan the Deployer'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
5
38
|
describe '#branch' do
|
6
39
|
it "delegates to fetch" do
|
7
40
|
expect(subject).to receive(:fetch).with(:branch)
|
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: 3.8.
|
4
|
+
version: 3.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Hallstrom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05
|
11
|
+
date: 2017-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|