get_version method returns HTTP 403

Bug #1570408 reported by Puneeth
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Python Jenkins
In Progress
Undecided
cburroughs

Bug Description

The get_version() method doesn't seem to work and raises a HTTPError exception.

how to reproduce this bug:

````
import jenkins

server = jenkins.Jenkins('https://jenkins.my-org.com', username='Puneeth-n', password='12345')

print server.get_version()
````

Solution:
Add authentication to HTTP headers.

I have submitted the code for review at master/fix/get_version

Revision history for this message
Lil (lil2006) wrote :

i have a bit different error on jenkins 2.1. Error communications with server

Revision history for this message
Khai Do (zaro0508) wrote :

@Puneeth, I assume you mean this change https://review.openstack.org/#/c/305882

if so the tests are failing for it so would you mind fixing up the tests?

Changed in python-jenkins:
assignee: nobody → cburroughs (chris-burroughs)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-jenkins (master)

Change abandoned by Sorin Sbarnea (<email address hidden>) on branch: master
Review: https://review.openstack.org/305882
Reason: This would have to be rewritten (if still needed) as we switched to use of requests library.

Revision history for this message
Gregory Shklover (gshklover) wrote :

Suggested fix:

    def get_version(self):
        response = self._session.get(self._build_url(''))
        return response.headers['X-Jenkins']

Revision history for this message
J D (jdearte) wrote :

This is still an issue with version 1.8.2

Interesting thing

If follow Example 1 - it works!

```
import jenkins

server = jenkins.Jenkins('http://localhost:8080', username='myuser', password='mypassword')
user = server.get_whoami()
version = server.get_version()
print('Hello %s from Jenkins %s' % (user['fullName'], version))
```

If I change the order of the calls (get_version before get_whoami), it will FAIL with 403

If I alter it to only call get_version, it will FAIL with 403

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.