salimfadhley/jenkinsapi — pull request #213 by pdunnigan (2013-11-26 22:02:39+00:00)
Title: error "Problem accessing /queue/api/python" when attempting parameterized build on jenkins server using prefix / context path

I was attempting a parameterized job build on a jenkins server setup using a prefix. For instance the url is "http://address:8080/jenkins". I received the following error from jenkins which was also confirmed by a customer:

```

Error 404 Not Found

HTTP ERROR: 404

Problem accessing /queue/api/python. Reason:

Not Found

Powered by Jetty://

```
The get_queue_url method in jenkins.py is using urlparse.urljoin which strips the context path off of the base_server_url. In this case it was stripping /jenkins off.

To replicate, setup a jenkins server and set JENKINS_ARGS="--prefix=/jenkins" and restart the server. Setup a project named "test" with a single build parameter, then run the following script before and after the patch. Note this script does not take auth into account.

```
from jenkinsapi.jenkins import Jenkins

def test():
j = Jenkins('http://myserver:8080/jenkins')
params = {}
params["BUILD"] = "xyz"
i = j['test'].invoke(build_params=params)

test()
```
One thing to note, there are other places where urlparse.urljoin() are used which may be affected by the content path / prefix. I did not test or touch those.