build-buddy 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d50fe65cd2806a970546102b56304bdae80f2b6
4
- data.tar.gz: 7fdd7e59a6b62df8fe884ec009020bdb85ec9cdd
3
+ metadata.gz: 8a552c3787d5d47a56a1e98766a255f7465f55e3
4
+ data.tar.gz: c7507aea8ea62bb171412ddb39aa2bdfa07463ca
5
5
  SHA512:
6
- metadata.gz: cdd33b96f5b8e83ec9eff07b0555038c03f629dca285de77975928d264ab68a5a6942d5550d0fedb4a01b0211757a55512dd66ea883f262abc30bbe03015d617
7
- data.tar.gz: afec166a8cce90aa46b85ff38bc3b4eddc8204afc2eeeca57a1b994dc75c151bcd6da50591d171fa772e259d65d5dfca6797a18f11cc0274d5f5e0504b362e18
6
+ metadata.gz: 7ea0e8ce598873347869fb3f7eec082b05b2ddde5811c2f26adbd988401fdcebc573bd2e7af3db062e744845c53b2f0dc003624a59cdb4f15c394687f37341ce
7
+ data.tar.gz: d5212a3ae04d87c742395759343dd810b93a159a6cbc6209a922b8c9c088718fd01fbacb15fa101a63d3c65aac152413956a7c50aa3cf2894c24986de7e90b2c
@@ -9,5 +9,5 @@ require 'build_buddy/recorder'
9
9
  require 'build_buddy/build_data'
10
10
 
11
11
  module BuildBuddy
12
- VERSION = "1.12.0"
12
+ VERSION = "1.12.1"
13
13
  end
@@ -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 != 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
- true
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.find { |build_data| build_data._id == id}
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
- true
62
+ return :in_queue
62
63
  end
63
64
 
64
- false
65
+ return :not_found
65
66
  end
66
67
 
67
68
  def on_build_interval
@@ -94,11 +94,13 @@ module BuildBuddy
94
94
  m = message.match(/[0-9abcdef]{24}/)
95
95
 
96
96
  unless m.nil?
97
- if Celluloid::Actor[:scheduler].stop_build(BSON::ObjectId.from_string(m[0]), slack_user_name)
98
- response = "OK#{is_from_slack_channel ? ' @' + slack_user_name : ''}, I stopped the build with identifier #{m[0]}."
99
- else
100
- response = "I could not find a queued or active build with that identifier"
101
- end
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
- response += ' ' + build_data.status_verb
158
- response += "\n"
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} (#{build_data._id.to_s})"
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 (#{build_data._id.to_s})"
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
- response += " (#{build_data._id.to_s})"
213
- response += "\n"
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
- when /build (.*)/i
289
- do_build $1, is_from_slack_channel, slack_user_name
290
- when /show(.*)/
291
- do_show $1
292
- when /help/i
293
- do_help is_from_slack_channel
294
- when /stop(?: build)(.*)/i
295
- do_stop $1, is_from_slack_channel, slack_user_name
296
- else
297
- "Sorry#{is_from_slack_channel ? ' ' + slack_user_name : ''}, I'm not sure how to respond."
298
- end
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.0
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-28 00:00:00.000000000 Z
11
+ date: 2016-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timers