bender-bot 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/bender/bot.rb +2 -2
- data/lib/bender/main.rb +29 -22
- 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: f4d54bc66c4adb36b8818f5e9d99690cfa9e1469
|
4
|
+
data.tar.gz: 8228afdc63456046fc27e1b92cc1f88a73c9063e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a9db7d32cc56a231060920ee4cce4518308c834d67ec2a0b27933dcf499f0bed4ae58c573a5daae024519cfccae70b5eb202cbb965050aeca1645f46a295a90
|
7
|
+
data.tar.gz: c910eb660ff6df14bc745d50c638d063dc2d3e4c5afe7518d5b82d57774eb128bd738f1f3a40679bf543b9846c012ccfcb7ca3200fef621bcfab9e32e6442d59
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.2
|
data/lib/bender/bot.rb
CHANGED
@@ -160,7 +160,7 @@ class BenderBot
|
|
160
160
|
unless status =~ /resolved|closed/i
|
161
161
|
'%s (%s - %s) [%s]: %s' % [
|
162
162
|
incident_link(i),
|
163
|
-
short_severity(i['fields'][SEVERITY_FIELD]['value']),
|
163
|
+
short_severity(i['fields'][SEVERITY_FIELD] && i['fields'][SEVERITY_FIELD]['value']),
|
164
164
|
normalize_value(i['fields']['status']),
|
165
165
|
friendly_date(i['fields']['created']),
|
166
166
|
i['fields']['summary']
|
@@ -191,7 +191,7 @@ class BenderBot
|
|
191
191
|
i['fields']['summary']
|
192
192
|
]
|
193
193
|
|
194
|
-
sev
|
194
|
+
sev = i['fields'][SEVERITY_FIELD]['value'] rescue ''
|
195
195
|
severities[sev] << repr
|
196
196
|
statuses[status] += 1
|
197
197
|
end
|
data/lib/bender/main.rb
CHANGED
@@ -134,7 +134,7 @@ module Bender
|
|
134
134
|
|
135
135
|
open_incidents = incidents.select do |i|
|
136
136
|
status = normalize_value i['fields']['status']
|
137
|
-
severity = short_severity(i['fields'][SEVERITY_FIELD]['value'])
|
137
|
+
severity = short_severity(i['fields'][SEVERITY_FIELD]['value']) rescue ''
|
138
138
|
is_open = !(status =~ /resolved|closed/i)
|
139
139
|
is_severe = severity =~ /(SEV1|SEV2)/i
|
140
140
|
is_open && is_severe
|
@@ -276,35 +276,42 @@ module Bender
|
|
276
276
|
|
277
277
|
|
278
278
|
def periodically_refresh_group bot
|
279
|
-
req_path = '/rest/api/2/group'
|
280
|
-
req_params = QueryParams.encode \
|
281
|
-
groupname: config[:jira_group],
|
282
|
-
expand: 'users'
|
283
|
-
|
284
|
-
uri = URI(config[:jira_site] + req_path + '?' + req_params)
|
285
|
-
http = Net::HTTP.new uri.hostname, uri.port
|
286
|
-
|
287
|
-
req = Net::HTTP::Get.new uri
|
288
|
-
req.basic_auth config[:jira_user], config[:jira_pass]
|
289
|
-
req['Content-Type'] = 'application/json'
|
290
|
-
req['Accept'] = 'application/json'
|
291
|
-
|
292
279
|
Thread.new do
|
293
280
|
loop do
|
294
281
|
begin
|
295
|
-
|
296
|
-
|
282
|
+
req_path = '/rest/api/2/group/member'
|
283
|
+
is_last, values, start = false, [], 0
|
284
|
+
until is_last
|
285
|
+
req_params = QueryParams.encode \
|
286
|
+
groupname: config[:jira_group],
|
287
|
+
startAt: start
|
288
|
+
|
289
|
+
uri = URI(config[:jira_site] + req_path + '?' + req_params)
|
290
|
+
http = Net::HTTP.new uri.hostname, uri.port
|
291
|
+
|
292
|
+
req = Net::HTTP::Get.new uri
|
293
|
+
req.basic_auth config[:jira_user], config[:jira_pass]
|
294
|
+
req['Content-Type'] = 'application/json'
|
295
|
+
req['Accept'] = 'application/json'
|
296
|
+
|
297
|
+
resp = http.request req
|
298
|
+
data = JSON.parse resp.body
|
299
|
+
values += data['values']
|
300
|
+
is_last = data['isLast']
|
301
|
+
start += data['maxResults']
|
302
|
+
end
|
303
|
+
|
304
|
+
user_names = values.map { |u| u['displayName'] }
|
305
|
+
bot.store['group'] = user_names
|
306
|
+
sleep config[:group_refresh]
|
307
|
+
|
297
308
|
rescue StandardError => e
|
298
309
|
log.error \
|
299
310
|
message: 'Could not periodically refresh group',
|
300
|
-
error: e.class
|
311
|
+
error: e.class,
|
312
|
+
data: resp.body
|
301
313
|
sleep 5
|
302
|
-
next
|
303
314
|
end
|
304
|
-
|
305
|
-
user_names = data['users']['items'].map { |u| u['displayName'] }
|
306
|
-
bot.store['group'] = user_names
|
307
|
-
sleep config[:group_refresh]
|
308
315
|
end
|
309
316
|
end
|
310
317
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bender-bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Clemmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02
|
11
|
+
date: 2016-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|