buildmeister 0.8.1 → 0.8.5
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.
- data/lib/buildmeister.rb +40 -17
- metadata +1 -1
data/lib/buildmeister.rb
CHANGED
@@ -6,6 +6,8 @@ require 'optparse'
|
|
6
6
|
class Buildmeister
|
7
7
|
attr_accessor :project, :project_name, :bin_groups, :notification_interval
|
8
8
|
|
9
|
+
RETRY_COUNT = 5
|
10
|
+
|
9
11
|
def initialize
|
10
12
|
@options = {}
|
11
13
|
OptionParser.new do |opts|
|
@@ -213,32 +215,53 @@ class Buildmeister
|
|
213
215
|
|
214
216
|
def notify
|
215
217
|
puts "Starting BuildMeister Notify..."
|
218
|
+
|
219
|
+
retry_count = RETRY_COUNT
|
220
|
+
|
221
|
+
loop do
|
222
|
+
begin
|
223
|
+
title = "BuildMeister: #{Time.now.strftime("%m/%d %I:%M %p")}"
|
216
224
|
|
217
|
-
|
218
|
-
title = "BuildMeister: #{Time.now.strftime("%m/%d %I:%M %p")}"
|
225
|
+
body = ''
|
219
226
|
|
220
|
-
|
227
|
+
bin_groups.each do |bin_group|
|
228
|
+
body += "#{bin_group[:name].titleize}\n"
|
229
|
+
body += "---------\n"
|
221
230
|
|
222
|
-
|
223
|
-
|
224
|
-
|
231
|
+
bin_group[:bin_names].each do |bin_name|
|
232
|
+
body += "#{bin_name}: #{display_value(bin_name)}\n"
|
233
|
+
end
|
225
234
|
|
226
|
-
|
227
|
-
body += "#{bin_name}: #{display_value(bin_name)}\n"
|
235
|
+
body += "\n"
|
228
236
|
end
|
229
237
|
|
230
|
-
|
231
|
-
end
|
238
|
+
puts "Updated notification at #{Time.now.strftime("%m/%d %I:%M %p")}"
|
232
239
|
|
233
|
-
|
240
|
+
if changed?
|
241
|
+
Buildmeister.post_notification(title, body)
|
242
|
+
end
|
234
243
|
|
235
|
-
|
236
|
-
Buildmeister.post_notification(title, body)
|
237
|
-
end
|
244
|
+
sleep notification_interval.minutes.to_i
|
238
245
|
|
239
|
-
|
240
|
-
|
241
|
-
|
246
|
+
reload_info
|
247
|
+
rescue StandardError => e
|
248
|
+
if retry_count < 1
|
249
|
+
puts "Retried #{RETRY_COUNT} times... I give up!"
|
250
|
+
raise e
|
251
|
+
else
|
252
|
+
# Exponential falloff...
|
253
|
+
sleep_time = 50 * (1 / (retry_count / 2))
|
254
|
+
|
255
|
+
puts "Caught error: #{e.class.name}: #{e.message}"
|
256
|
+
puts "#{retry_count} more tries... sleeping #{sleep_time} seconds..."
|
257
|
+
|
258
|
+
sleep sleep_time
|
259
|
+
|
260
|
+
retry_count -= 1
|
261
|
+
|
262
|
+
retry
|
263
|
+
end
|
264
|
+
end
|
242
265
|
end
|
243
266
|
end
|
244
267
|
|