From b97c31f9dd1423612759ae22daf0b6abafa66c37 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Tue, 22 Apr 2014 16:23:45 +0200 Subject: [PATCH] Clarify job_exists() error messages To verify a job exist, we query Jenkins API and attempt to load the resulting JSON. The error message is very simple: Jenkins returned an unexpected job name This patch add the actual job name received and the expected one. That might help diagnosis. Change-Id: Ib13c3bb8d265612811714d10818364956f84a341 --- jenkins/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jenkins/__init__.py b/jenkins/__init__.py index 215bc7c..3145943 100644 --- a/jenkins/__init__.py +++ b/jenkins/__init__.py @@ -199,10 +199,12 @@ class Jenkins(object): response = self.jenkins_open( urllib2.Request(self.server + JOB_NAME % locals())) if response: - if json.loads(response)['name'] != name: + actual = json.loads(response)['name'] + if actual != name: raise JenkinsException( - 'Jenkins returned an unexpected job name') - return json.loads(response)['name'] + 'Jenkins returned an unexpected job name %s ' + '(expected: %s)' % (actual, name)) + return actual else: return None