pycontribs / jenkinsapi

A Python API for accessing resources and configuring Hudson & Jenkins continuous-integration servers
http://pypi.python.org/pypi/jenkinsapi
MIT License
859 stars 485 forks source link

get_job is failing against jenkins2.0 with allBuilds key error #653

Closed Kaushikroy05 closed 5 years ago

Kaushikroy05 commented 6 years ago
ISSUE TYPE
Jenkinsapi VERSION

0.3.6

Jenkins VERSION

2.0

SUMMARY

The get_job(job name) call against jenkins2.0 fails. It passes for freestyle jenkins 1,7 . In the following traceback the "response" variable is empty in case of jenkins version 2.0. However for freestyle jenkins the "response" is a dictionary with only one key "allBuilds".

Ant advise will be helpful.

KeyError Traceback (most recent call last)

in () ----> 1 server1.get_job("sbusw-nf-bullseye") /usr/lib/python3.5/site-packages/jenkinsapi/jenkins.py in get_job(self, jobname) 136 :return: Job obj 137 """ --> 138 return self.jobs[jobname] 139 140 def has_job(self, jobname): /usr/lib/python3.5/site-packages/jenkinsapi/jobs.py in __getitem__(self, job_name) 84 job_row['url'], 85 self.jenkins.baseurl) == job_name][0] ---> 86 return Job(job_data['url'], job_data['name'], self.jenkins) 87 else: 88 raise UnknownJob(job_name) /usr/lib/python3.5/site-packages/jenkinsapi/job.py in __init__(self, url, name, jenkins_obj) 66 } 67 self.url = url ---> 68 JenkinsBase.__init__(self, self.url) 69 70 def __str__(self): /usr/lib/python3.5/site-packages/jenkinsapi/jenkinsbase.py in __init__(self, baseurl, poll) 33 self.baseurl = self.strip_trailing_slash(baseurl) 34 if poll: ---> 35 self.poll() 36 37 def get_jenkins_obj(self): /usr/lib/python3.5/site-packages/jenkinsapi/job.py in poll(self, tree) 92 data = super(Job, self).poll(tree=tree) 93 if not tree: ---> 94 self._data = self._add_missing_builds(self._data) 95 else: 96 return data /usr/lib/python3.5/site-packages/jenkinsapi/job.py in _add_missing_builds(self, data) 119 return data 120 response = self.poll(tree='allBuilds[number,url]') --> 121 data['builds'] = response['allBuilds'] 122 return data 123 KeyError: 'allBuilds' ##### EXPECTED RESULTS I expected job details to be returned. ##### ACTUAL RESULTS Key Error for allBuilds. ##### USEFUL INFORMATION ``` ```
behanna commented 6 years ago

Further information: the server against which we are seeing the above exception is running Jenkins 2.107.1, runs pipeline jobs exclusively, and is using the CloudBees Folders Plugin. We have passed the full URL to the folder that contains our jobs as the url to the jenkinsapi.jenkins.Jenkins() constructor; else we weren't even getting this far.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

Closed due to inactivity