Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Jenkins(jenkins_url, auth=(user,token)), jenkins_url changes port to 80 #68

Closed
exsell-jc opened this issue Nov 1, 2022 · 2 comments

Comments

@exsell-jc
Copy link

exsell-jc commented Nov 1, 2022

At first, the Jenkins API makes the connection well. However, when it gets to post, it changes.

Is it possible to make the Jenkins API just strictly follow the input parameter http://1.2.3.4:8080/jenkins instead?

2022-11-01 16:35:10,635 DEBUG    [ retry | from_int ] Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
2022-11-01 16:35:10,635 DEBUG    [ requester | send ] GET: http://1.2.3.4:8080/jenkins/crumbIssuer/api/json with parameters: {}
2022-11-01 16:35:10,638 DEBUG    [ connectionpool | _new_conn ] Starting new HTTP connection (1): 1.2.3.4:8080
2022-11-01 16:35:10,643 DEBUG    [ connectionpool | _make_request ] http://1.2.3.4:8080 "GET /jenkins/crumbIssuer/api/json HTTP/1.1" 200 155
2022-11-01 16:35:10,644 DEBUG    [ requester | send ] Response: <Response [200]>
2022-11-01 16:35:10,645 DEBUG    [ requester | send ] GET: http://1.2.3.4:8080/jenkins/ with parameters: {'headers': {'Jenkins-Crumb': '699fc00f48ee20ec273953d41cf2387239a30cc39219b55fff5849ce69e7e65d'}}
2022-11-01 16:35:10,673 DEBUG    [ connectionpool | _make_request ] http://1.2.3.4:8080 "GET /jenkins/ HTTP/1.1" 200 11463
2022-11-01 16:35:10,675 DEBUG    [ requester | send ] Response: <Response [200]>
2022-11-01 16:35:10,676 DEBUG    [ requester | send ] GET: http://1.2.3.4:8080/jenkins/api/json with parameters: {'headers': {'Jenkins-Crumb': '699fc00f48ee20ec273953d41cf2387239a30cc39219b55fff5849ce69e7e65d'},
 'params': {'depth': 0, 'tree': '_class'}}
2022-11-01 16:35:10,682 DEBUG    [ connectionpool | _make_request ] http://1.2.3.4:8080 "GET /jenkins/api/json?depth=0&tree=_class HTTP/1.1" 200 48
2022-11-01 16:35:10,683 DEBUG    [ requester | send ] Response: <Response [200]>
2022-11-01 16:35:10,683 DEBUG    [ requester | send ] GET: http://1.2.3.4:8080/jenkins/api/json with parameters: {'headers': {'Jenkins-Crumb': '699fc00f48ee20ec273953d41cf2387239a30cc39219b55fff5849ce69e7e65d'},
 'params': {'depth': 0, 'tree': 'jobs[name,url]'}}
2022-11-01 16:35:10,690 DEBUG    [ connectionpool | _make_request ] http://1.2.3.4:8080 "GET /jenkins/api/json?depth=0&tree=jobs%5Bname%2Curl%5D HTTP/1.1" 200 964
2022-11-01 16:35:10,691 DEBUG    [ requester | send ] Response: <Response [200]>
2022-11-01 16:35:10,691 DEBUG    [ requester | send ] POST: http://docker.mywebsite.com/jenkins/job/JENKINS_TASK/buildWithParameters with parameters: {'headers': {'Jenkins-Crumb': '699fc00f48ee20ec273953d41cf2387239a30cc39219b55fff5849ce69e7e65d'},
 'params': {'x': 'x',
            'y': y,
            'z': 'z',
            'a': 'a',
            'b': 'b'}}
2022-11-01 16:35:10,693 DEBUG    [ connectionpool | _new_conn ] Starting new HTTP connection (1): docker.mywebsite.com:80
...

In the last line (and the line before): 2022-11-01 16:35:10,693 DEBUG [ connectionpool | _new_conn ] Starting new HTTP connection (1): docker.mywebsite.com:80
You can see, instead of the IP address + 8080 port number, it changes.

I also tried with Jenkins(jenkins_url, auth=(user, token), allow_redirects=False, verify=False) but doubting I did it right and/or if it did anything. I got the kwargs from here which redirected me to here.

I saw this previous GitHub issue, but unsure how to understand the conversation at the end -- a bit vague.

@exsell-jc exsell-jc changed the title In Jenkins(jenkins_url, auth=(user,token)), jenkins_url obeys /etc/hosts too strictly In Jenkins(jenkins_url, auth=(user,token)), jenkins_url changes port to 80 Nov 2, 2022
@PathosEthosLogos
Copy link

The API obeys the port number set in Manage Jenkins -> Configure System -> Jenkins URL, but not the subdirectory.
It seems that api4jenkins doesn't have a way to POST to a subdirectory.

@joelee2012
Copy link
Owner

joelee2012 commented Nov 4, 2022

@exsell-jc where do you run the Jenkins, and what's the value of Manage Jenkins -> Configure System -> Jenkins URL ?
if your jenkins run with subpath, add the subpath in to url as well, see doc of this property

Optionally specify the HTTP address of the Jenkins installation, such as http://yourhost.yourdomain/jenkins/ . This value is used to let Jenkins know how to refer to itself, ie. to display images or to create links in emails.

the issue #9 was because he started Jenkins in vm with port 8080 map 9090 of host, so if post request from vm, the Jenkins URL should be localhost:8080, if post from host it should be localhost:9090

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants