build-buddy 1.12.0 → 1.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/build_buddy.rb +1 -1
- data/lib/build_buddy/scheduler.rb +6 -5
- data/lib/build_buddy/slacker.rb +44 -24
- 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: 8a552c3787d5d47a56a1e98766a255f7465f55e3
|
4
|
+
data.tar.gz: c7507aea8ea62bb171412ddb39aa2bdfa07463ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ea0e8ce598873347869fb3f7eec082b05b2ddde5811c2f26adbd988401fdcebc573bd2e7af3db062e744845c53b2f0dc003624a59cdb4f15c394687f37341ce
|
7
|
+
data.tar.gz: d5212a3ae04d87c742395759343dd810b93a159a6cbc6209a922b8c9c088718fd01fbacb15fa101a63d3c65aac152413956a7c50aa3cf2894c24986de7e90b2c
|
data/lib/build_buddy.rb
CHANGED
@@ -45,23 +45,24 @@ module BuildBuddy
|
|
45
45
|
|
46
46
|
def stop_build(id, slack_user_name)
|
47
47
|
# Centralize stopping builds here
|
48
|
-
if @active_build != nil and @active_build._id
|
48
|
+
if @active_build != nil and @active_build._id == id
|
49
49
|
@active_build.stopped_by = slack_user_name
|
50
50
|
Celluloid::Actor[:builder].stop_build
|
51
|
-
|
51
|
+
# Build data will be recorded when the build stops
|
52
|
+
return :active
|
52
53
|
end
|
53
54
|
|
54
55
|
# Look for the build in the queue
|
55
|
-
i = @build_queue.
|
56
|
+
i = @build_queue.find_index { |build_data| build_data._id == id}
|
56
57
|
if i != nil
|
57
58
|
build_data = @build_queue[i]
|
58
59
|
@build_queue.delete_at(i)
|
59
60
|
build_data.stopped_by = slack_user_name
|
60
61
|
Celluloid::Actor[:recorder].async.record_build_data(build_data)
|
61
|
-
|
62
|
+
return :in_queue
|
62
63
|
end
|
63
64
|
|
64
|
-
|
65
|
+
return :not_found
|
65
66
|
end
|
66
67
|
|
67
68
|
def on_build_interval
|
data/lib/build_buddy/slacker.rb
CHANGED
@@ -94,11 +94,13 @@ module BuildBuddy
|
|
94
94
|
m = message.match(/[0-9abcdef]{24}/)
|
95
95
|
|
96
96
|
unless m.nil?
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
97
|
+
result = Celluloid::Actor[:scheduler].stop_build(BSON::ObjectId.from_string(m[0]), slack_user_name)
|
98
|
+
response = case result
|
99
|
+
when :active, :in_queue
|
100
|
+
"OK#{is_from_slack_channel ? ' @' + slack_user_name : ''}, I #{result == :active ? "stopped" : "dequeued"} the build with identifier #{m[0]}."
|
101
|
+
when :not_found
|
102
|
+
"I could not find a queued or active build with that identifier"
|
103
|
+
end
|
102
104
|
else
|
103
105
|
response = "You must specify the 24 digit hexadecimal build identifier. It can be an active build or a build in the queue."
|
104
106
|
end
|
@@ -154,8 +156,14 @@ Build metrics and charts are available at #{Config.server_base_uri}/hud/#{Config
|
|
154
156
|
"pull request build #{build_data.pull_request_uri}"
|
155
157
|
end
|
156
158
|
response += " at #{build_data.start_time.to_s}. #{Config.server_base_uri + '/log/' + build_data._id.to_s}"
|
157
|
-
|
158
|
-
|
159
|
+
unless build_data.started_by.nil?
|
160
|
+
response += " started by #{build_data.started_by}"
|
161
|
+
end
|
162
|
+
unless build_data.stopped_by.nil?
|
163
|
+
response += " stopped by #{build_data.stopped_by}"
|
164
|
+
end
|
165
|
+
response += " #{build_data.status_verb}"
|
166
|
+
response += ".\n"
|
159
167
|
end
|
160
168
|
end
|
161
169
|
when /status/
|
@@ -173,12 +181,15 @@ Build metrics and charts are available at #{Config.server_base_uri}/hud/#{Config
|
|
173
181
|
else
|
174
182
|
case build_data.type
|
175
183
|
when :pull_request
|
176
|
-
response = "There is a pull request build in progress for https://github.com/#{build_data.repo_full_name}/pull/#{build_data.pull_request} (
|
184
|
+
response = "There is a pull request build in progress for https://github.com/#{build_data.repo_full_name}/pull/#{build_data.pull_request} (identifier `#{build_data._id.to_s}`)"
|
177
185
|
when :branch
|
178
|
-
response = "There is a build of the `#{build_data.branch}` branch of https://github.com/#{build_data.repo_full_name} in progress (
|
186
|
+
response = "There is a build of the `#{build_data.branch}` branch of https://github.com/#{build_data.repo_full_name} in progress (identifier `#{build_data._id.to_s}`)"
|
179
187
|
end
|
180
188
|
unless build_data.started_by.nil?
|
181
|
-
response += build_data.started_by
|
189
|
+
response += " started by " + build_data.started_by
|
190
|
+
end
|
191
|
+
unless build_data.stopped_by.nil?
|
192
|
+
response += " stopped by #{build_data.stopped_by}"
|
182
193
|
end
|
183
194
|
response += '.'
|
184
195
|
if queue_length == 1
|
@@ -206,11 +217,14 @@ Build metrics and charts are available at #{Config.server_base_uri}/hud/#{Config
|
|
206
217
|
when :pull_request
|
207
218
|
"pull request build #{build_data.pull_request_uri}"
|
208
219
|
end
|
220
|
+
response += " (identifier `#{build_data._id.to_s}`)"
|
209
221
|
unless build_data.started_by.nil?
|
210
|
-
response += " by #{build_data.started_by}"
|
222
|
+
response += " started by #{build_data.started_by}"
|
211
223
|
end
|
212
|
-
|
213
|
-
|
224
|
+
unless build_data.stopped_by.nil?
|
225
|
+
response += " stopped by #{build_data.stopped_by}"
|
226
|
+
end
|
227
|
+
response += ".\n"
|
214
228
|
}
|
215
229
|
end
|
216
230
|
else
|
@@ -285,17 +299,19 @@ Build metrics and charts are available at #{Config.server_base_uri}/hud/#{Config
|
|
285
299
|
end
|
286
300
|
|
287
301
|
response = case message
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
302
|
+
when /^ *build (.*)/i
|
303
|
+
do_build $1, is_from_slack_channel, slack_user_name
|
304
|
+
when /^ *status/ # Legacy support
|
305
|
+
do_show 'status'
|
306
|
+
when /^ *show(.*)/
|
307
|
+
do_show $1
|
308
|
+
when /^ *help/i
|
309
|
+
do_help is_from_slack_channel
|
310
|
+
when /^ *stop(?: build)(.*)/i
|
311
|
+
do_stop $1, is_from_slack_channel, slack_user_name
|
312
|
+
else
|
313
|
+
"Sorry#{is_from_slack_channel ? ' ' + slack_user_name : ''}, I'm not sure how to respond."
|
314
|
+
end
|
299
315
|
@rt_client.message channel: data['channel'], text: response
|
300
316
|
info "Slack message '#{message}' from #{data['channel']} handled"
|
301
317
|
end
|
@@ -311,6 +327,10 @@ Build metrics and charts are available at #{Config.server_base_uri}/hud/#{Config
|
|
311
327
|
info "Pull request build #{status_verb}"
|
312
328
|
end
|
313
329
|
|
330
|
+
if build_data.termination_type == :killed and build_data.stopped_by != nil
|
331
|
+
message += " by #{build_data.stopped_by}"
|
332
|
+
end
|
333
|
+
|
314
334
|
message += ". Log file at #{build_data.server_log_uri}"
|
315
335
|
|
316
336
|
# See https://api.slack.com/docs/attachments for more information about formatting Slack attachments
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build-buddy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Lyon-smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: timers
|