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
This commit is contained in:
Antoine Musso 2014-04-22 16:23:45 +02:00
parent 5269924155
commit b97c31f9dd

View File

@ -199,10 +199,12 @@ class Jenkins(object):
response = self.jenkins_open( response = self.jenkins_open(
urllib2.Request(self.server + JOB_NAME % locals())) urllib2.Request(self.server + JOB_NAME % locals()))
if response: if response:
if json.loads(response)['name'] != name: actual = json.loads(response)['name']
if actual != name:
raise JenkinsException( raise JenkinsException(
'Jenkins returned an unexpected job name') 'Jenkins returned an unexpected job name %s '
return json.loads(response)['name'] '(expected: %s)' % (actual, name))
return actual
else: else:
return None return None