get_info() ignores query argument

Bug #1771319 reported by ercpe
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Python Jenkins
New
Undecided
Unassigned

Bug Description

With python-jenkins >= 1.0.0, the parameter 'query' of the get_info() method is ignored:

        url = '/'.join((item, INFO)).lstrip('/')
        url = quote(url)
        if query:
            url += query
        try:
            return json.loads(self.jenkins_open(
                requests.Request('GET', self._build_url(INFO))
            ))
        except (req_exc.HTTPError, BadStatusLine):
            ....

The query parameter is used to construct the url which isn't passed to the actual request. As a result, all calls to get_info() return only the mninimal job fields.

Revision history for this message
Roscoe Pyell (roscoejp) wrote :

This also effects any other function calls that rely on queries passed to get_info - which after a quick ctrl+f appears to be just get_all_jobs() atm.

Since _build_url() is used for constructing the url with base, it should be a relatively simple fix of replacing 'INFO' with 'url' to get this functioning as described. It might also be good to set url = INFO before checking for the existence of item or query to keep the current functionality available as a call to get_info() without any params.

I'll work on a PR for this later if I have time. It's such a simple fix but has caused headaches for me over the past 2 days after finding that get_all_jobs() didn't actually work as advertised.

ercpe@ - you can work around this by making your own call to your instance with your query:

j = jenkins.Jenkins(...)
query = '?tree=views[name]'
url = jenkins.INFO + QUERY
results = j.jenkins_open(jenkins.requests.Request('GET', j._build_url(url)))

Revision history for this message
ercpe (ercpe) wrote :

Yes, this is more or less what I had as a fix in mind. For the meantime, we've frozen the dependency at 0.4.16 where the get_info() method works as expected.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.