buildmeister 0.8.1 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/buildmeister.rb +40 -17
  2. 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
- loop do
218
- title = "BuildMeister: #{Time.now.strftime("%m/%d %I:%M %p")}"
225
+ body = ''
219
226
 
220
- body = ''
227
+ bin_groups.each do |bin_group|
228
+ body += "#{bin_group[:name].titleize}\n"
229
+ body += "---------\n"
221
230
 
222
- bin_groups.each do |bin_group|
223
- body += "#{bin_group[:name].titleize}\n"
224
- body += "---------\n"
231
+ bin_group[:bin_names].each do |bin_name|
232
+ body += "#{bin_name}: #{display_value(bin_name)}\n"
233
+ end
225
234
 
226
- bin_group[:bin_names].each do |bin_name|
227
- body += "#{bin_name}: #{display_value(bin_name)}\n"
235
+ body += "\n"
228
236
  end
229
237
 
230
- body += "\n"
231
- end
238
+ puts "Updated notification at #{Time.now.strftime("%m/%d %I:%M %p")}"
232
239
 
233
- puts "Updated notification at #{Time.now.strftime("%m/%d %I:%M %p")}"
240
+ if changed?
241
+ Buildmeister.post_notification(title, body)
242
+ end
234
243
 
235
- if changed?
236
- Buildmeister.post_notification(title, body)
237
- end
244
+ sleep notification_interval.minutes.to_i
238
245
 
239
- sleep notification_interval.minutes.to_i
240
-
241
- reload_info
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildmeister
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leigh Caplan