pycontribs / jenkinsapi

A Python API for accessing resources and configuring Hudson & Jenkins continuous-integration servers
http://pypi.python.org/pypi/jenkinsapi
MIT License
858 stars 485 forks source link

a problem with old jenkins #808

Closed gittor closed 3 years ago

gittor commented 3 years ago
ISSUE TYPE
Jenkinsapi 0.3.11
Jenkins 2.190.3
SUMMARY
jenkins_url = "http://10.10.12.29:8080"
server = Jenkins(jenkins_url, username="********", password="********")
print server.get_jobs()

when I run the code, JenkinsBase.get_data() returns jobs with url http://localhost:8080.like

"jobs": [{
        "_class": "hudson.model.FreeStyleProject",
        "name": "xxx",
        "url": "http://localhost:8080/job/xxxx/",
        "color": "aborted"
    }, {
        "_class": "hudson.model.FreeStyleProject",
        "name": "yyyy",
        "url": "http://localhost:8080/job/yyyy/",
        "color": "blue"
    }
}

but the 10.10.12.29 is not my ip, then Jenkins.py raises an exception.

joelee2012 commented 3 years ago

@gittor maybe you want to try https://api4jenkins.readthedocs.io/en/latest/user/example.html#jenkins

gjabouley-invn commented 3 years ago

Hello, it could be a Jenkins misconfiguration. What is configured for "Manage Jenkins-> Configure System -> Jenkins URL"? It should be set explicitly to http://10.10.12.29:8080

gittor commented 3 years ago

Hello, it could be a Jenkins misconfiguration. What is configured for "Manage Jenkins-> Configure System -> Jenkins URL"? It should be set explicitly to http://10.10.12.29:8080

Thank you. Now I'm curious about why jenkins behaves like this. Why it doesn't read the computer's ip

gjabouley-invn commented 3 years ago

Jenkins cannot know its own url, assuming you can host it:

Best practice is to set the url to access Jenkins in this field. It is then used to generate urls in email for example, and also in http headers.

gittor commented 3 years ago

Thank you all