python-jenkins-developers team mailing list archive
-
python-jenkins-developers team
-
Mailing list archive
-
Message #00495
[Bug 1724932] Re: build_job() always returns an empty string, no way to track resulting ID
I, also, would like a change like this. However, I couldn't figure out
how to apply the previous patch, nor do I know how to use Gerrit. I'm
inlining the patch I'm maintaining, locally. I'm about 90% sure I don't
match style (the PEP...?), there's probably insufficient error handling,
etc. Sorry if this doesn't help.
421c421
< def jenkins_open(self, req, add_crumb=True):
---
> def jenkins_open(self, req, add_crumb=True, return_qid=False):
431c431,432
< response = urlopen(req, timeout=self.timeout).read()
---
> rresponse = urlopen(req, timeout=self.timeout)
> response = rresponse.read()
436c437,444
< return response.decode('utf-8')
---
> if not return_qid:
> return response.decode('utf-8')
> else:
> if rresponse is None or 'location' not in rresponse.info():
> raise EmptyResponseException(
> "Error communicating with server[%s]:"
> "bad response" % self.server)
> return int(rresponse.info()['location'].strip('/').split('/')[-1])
1051c1059
< self.build_job_url(name, parameters, token), b''))
---
> self.build_job_url(name, parameters, token), b''), return_qid=True)
--
You received this bug notification because you are a member of Python
Jenkins Developers, which is subscribed to Python Jenkins.
https://bugs.launchpad.net/bugs/1724932
Title:
build_job() always returns an empty string, no way to track resulting
ID
Status in Python Jenkins:
In Progress
Bug description:
Since Jenkins version 1.519 (released 2013/06/17), build_job() always
returns an empty string (the empty HTTP body from the POST request).
The Jenkins REST API currently returns an HTTP response with a
"Location" header that includes a queue item number for the job. This
queue item number is only valid for a few minutes until Jenkins
removes it from memory, but in the meantime, while it's available,
clients can poll it to find the eventual job ID / URL.
Instead of returning the HTTP response body, we should parse this
Location HTTP header and return the queue ID. This will require a new
jenkins_urlopen() method, since the main jenkins_open() method only
returns the body without regard for any headers.
We can also implement a get_queue_item() method to discover a queued
job's status, and possibly a job URL.
To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1724932/+subscriptions
References