2016-11-28 133 views
0

我想打印「詹金斯版本」和「招聘信息」的Python [錯誤110]連接超時 - 無法建立連接

它打印「詹金斯版本」,但不是「工作細節」

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', '[email protected]') 
    print(server.version) 
    jobs = server.get_jobs() 
    for job in jobs: 
     print(job) 

1)我能夠對端口號443和(2)我能ping 'jenkins.com' 使用IP

錯誤消息的telnet 'jenkins.com' - 無法建立連接

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',)) 

任何幫助,高度讚賞

+0

你確定與jenkins_url的價值?在瀏覽器中粘貼它給了我一個404.我應該做的是將jenkins_url指向jenkins運行的tomcat實例... –

+1

@Vivek詹金斯URL我提到的是一個僞(或)虛擬URL –

+0

你提到telnet,但錯誤消息顯示端口8080處的嘗試https連接;你有沒有檢查過那個工程?例如,嘗試在'https://6.4.2.182:8080/scm/jenkins/job/DO%20NOT%20CHANGE%20THIS%20PROJECT/api/python'上使用curl。 – Evert

回答

0

問題已在詹金斯提正確的「BASE URL」解決 - >管理詹金斯 - >配置系統 - >詹金斯URL

相關問題