get_version() throws jenkins.BadHTTPException when login is required

Bug #1826802 reported by Bao Haojun
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python Jenkins
New
Undecided
Unassigned

Bug Description

Our site is set up so that all users need to login first, before they can see anything.

Because of that, when I call get_version, it will fail with the following:

    >>> server.get_version()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/bhj/.linuxbrew/Cellar/python@2/2.7.16/lib/python2.7/site-packages/jenkins/__init__.py", line 835, in get_version
        % self.server)
    jenkins.BadHTTPException: Error communicating with server[server url]

It can be fixed by the following patch:

    diff --git a/jenkins/__init__.py b/jenkins/__init__.py
    index 9717f58..b443756 100755
    --- a/jenkins/__init__.py
    +++ b/jenkins/__init__.py
    @@ -826,7 +826,7 @@ class Jenkins(object):
             try:
                 request = requests.Request('GET', self._build_url(''))
                 request.headers['X-Jenkins'] = '0.0'
    - response = self._response_handler(self._request(request))
    + response = self.jenkins_request(request)

                 return response.headers['X-Jenkins']

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.