Skip to content

Commit 6ffec49

Browse files
authored
Merge pull request RobustPerception#1 from turb/master
Fix error when a job is mostly empty
2 parents 9744e78 + aa60711 commit 6ffec49

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

jenkins_exporter/jenkins_exporter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ def collect(self):
5050
name = job['name']
5151
for s in statuses:
5252
# If there's a null result, we want to export zeros.
53-
status = job[s] or {}
53+
if s in job and job[s]:
54+
status=job[s]
55+
else:
56+
status={}
5457
metrics[s]['number'].add_metric([name], status.get('number', 0))
5558
metrics[s]['duration'].add_metric([name], status.get('duration', 0) / 1000.0)
5659
metrics[s]['timestamp'].add_metric([name], status.get('timestamp', 0) / 1000.0)

0 commit comments

Comments
 (0)