Unwanted [forward] slash in get_info results 404 error in case server url looks like "http://domainname[:port]/myjenkins"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python Jenkins |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Function get_info with default value of parameter item uses wrong url to send request to Jenkins server in case server url looks like "http://
source code of python-
437 def get_info(self, item="", query=None):
.....
.....
456 url = "/".join((item, INFO))
457 if query:
458 url += query
459 try:
460 return json.loads(
461 Request(
with INFO='api/json' and item="" works like this:
>>> item = ""
>>> url = "/".join((item, 'api/json'))
>>> print url
/api/json
As a result function _build_url produces wrong url with self.server="http://
>>> from six.moves.
>>> urljoin(
'http://
>>> print self.server
http://
>>> urljoin(
'http://
Functions get_jobs and get_all_jobs are affected by this issue.
>>>import jenkins
>>>server = jenkins.Jenkins('http://
>>>version = server.
>>> print version
1.565.3
>>> jobs = server.get_jobs()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/
return self.get_
File "/usr/local/
jobs = [(0, "", self.get_
File "/usr/local/
Request(
File "/usr/local/
raise NotFoundExcepti
jenkins.
>>> info = server.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/
Request(
File "/usr/local/
raise NotFoundExcepti
jenkins.
Jenkins is accessible by using "http://
As I can see in access logs the 404 code was returned because of wrong address in request :
xx.xx.0.24 - - [29/Sep/
xx.xx.0.24 - - [29/Sep/
It should send request to "GET /jenkins/
Jenkins is working properly. It was checked by wget --auth-no-challenge --http-user=jenkins --http-
Record from access log:
xx.xx.0.24 - - [29/Sep/
I've tested fix and would like to push it back to project:
-bash-4.1$ git diff
diff --git a/jenkins/
index ca46fd7..4677bdb 100644
--- a/jenkins/
+++ b/jenkins/
@@ -453,7 +453,10 @@ class Jenkins(object):
"""
- url = "/".join((item, INFO))
+ if item != '':
+ url = "/".join((item, INFO))
+ else:
+ url = INFO
if query:
url += query
try:
This fix should not broke functionality "Adds Cloudbees folder plugin support" https:/
Project "openstack-
Changed in python-jenkins: | |
assignee: | nobody → Anton Haldin (anton-haldin) |
Changed in python-jenkins: | |
assignee: | Anton Haldin (anton-haldin) → nobody |
I have the same issue.
My jenkins is at http:// ci.localdomain: 8081/jenkins/
I got the same stack trace and I confirm that the patch proposed here worked for me.