From aa60711b7cc70d32435b296248dbf24db6fb93f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylvain=20Veyri=C3=A9?= Date: Thu, 24 May 2018 11:13:53 +0200 Subject: [PATCH] Fix None case --- jenkins_exporter/jenkins_exporter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jenkins_exporter/jenkins_exporter.py b/jenkins_exporter/jenkins_exporter.py index 3ab8176..2eaf234 100755 --- a/jenkins_exporter/jenkins_exporter.py +++ b/jenkins_exporter/jenkins_exporter.py @@ -50,7 +50,10 @@ def collect(self): name = job['name'] for s in statuses: # If there's a null result, we want to export zeros. - status = job[s] or {} + if s in job and job[s]: + status=job[s] + else: + status={} metrics[s]['number'].add_metric([name], status.get('number', 0)) metrics[s]['duration'].add_metric([name], status.get('duration', 0) / 1000.0) metrics[s]['timestamp'].add_metric([name], status.get('timestamp', 0) / 1000.0)