Python [错误110]连接超时 - 无法建立连接

时间:2016-11-28 06:13:53

标签: python jenkins

我试图打印詹金斯版本'和'工作细节'

它打印詹金斯版本'但不是'工作细节'

a)  I work on Ubuntu 16.04
b)  Two version of python exists 2.7.6 and 3.4.3 and am using 'version 2.7.6'
c)  I used 'pip install jenkinsapi' to install 'jenkinsapi'

#!/usr/bin/python
import sys
sys.path.append('/usr/local/lib/python2.7/dist-packages/')

import urllib3
from jenkinsapi.jenkins import Jenkins

if __name__ == '__main__':
    jenkins_url = 'http://jenkins.com/b/jenkins/'
    server = Jenkins(jenkins_url, 'kailass', 'Newpassword@123')
    print(server.version)
    jobs = server.get_jobs()
    for job in jobs:
        print(job)

1)我能够telnet' jenkins.com'在443号港口和(2)我能够ping通jenkins.com'使用其IP

错误消息 - 无法建立连接

Traceback (most recent call last):
  File "jenver.py", line 33, in <module>
    for job in jobs:
  File "/usr/local/lib/python2.7/dist-packages/jenkinsapi/jobs.py", line 91, in iteritems
    for job in self.itervalues():
  File "/usr/local/lib/python2.7/dist-packages/jenkinsapi/jobs.py", line 116, in itervalues
    yield Job(row['url'], row['name'], self.jenkins)
  File "/usr/local/lib/python2.7/dist-packages/jenkinsapi/job.py", line 74, in __init__
    JenkinsBase.__init__(self, self.url)
  File "/usr/local/lib/python2.7/dist-packages/jenkinsapi/jenkinsbase.py", line 35, in __init__
    self.poll()
  File "/usr/local/lib/python2.7/dist-packages/jenkinsapi/job.py", line 98, in poll
    data = super(Job, self).poll(tree=tree)
  File "/usr/local/lib/python2.7/dist-packages/jenkinsapi/jenkinsbase.py", line 59, in poll
    data = self._poll(tree=tree)
  File "/usr/local/lib/python2.7/dist-packages/jenkinsapi/jenkinsbase.py", line 69, in _poll
    return self.get_data(url, tree=tree)
  File "/usr/local/lib/python2.7/dist-packages/jenkinsapi/jenkinsbase.py", line 79, in get_data
    response = requester.get_url(url, params)
  File "/usr/local/lib/python2.7/dist-packages/jenkinsapi/utils/requester.py", line 109, in get_url
    return requests.get(self._update_url_scheme(url), **requestKwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 487, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='6.4.2.182', port=8080): Max retries exceeded with url: /scm/jenkins/job/DO%20NOT%20CHANGE%20THIS%20PROJECT/api/python (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f66c65eab50>: Failed to establish a new connection: [Errno 110] Connection timed out',))

非常感谢任何帮助

1 个答案:

答案 0 :(得分:0)

通过在Jenkins中提及正确的“BASE URL”来解决该问题 - &gt;管理Jenkins - &gt;配置系统 - &gt;詹金斯网址