呼吁JenkinsAPI(HTTPS)刚刚挂起(Call to JenkinsAPI(https)

2019-09-29 19:19发布

我下面的代码给出

from jenkinsapi.jenkins import Jenkins

def get_server_instance():
    jenkins_url = 'https://<privateJenkinsServer>:<port>'
    print "Hello" 
   server = Jenkins(jenkins_url, username = 'foouser', password = 'foopassword')
    return server

if __name__ == '__main__':
    print get_server_instance().version

当我执行此,它只是打印“Hello”,然后挂断。 可能是什么原因呢?

NB我在我的身后代理公司网络上运行这一点。

参考: http://pythonhosted.org/jenkinsapi/using_jenkinsapi.html#example-1-get-version-of-jenkins

当我杀的命令,我碰到下面的错误。

File "C:\Python27\lib\ssl.py", line 643, in read
    v = self._sslobj.read(len)

完整的日志。

>>> execfile('C:\Users\idatta\Project\Python\Demo\JenkinsAPI_v1.py')
started
https://jenkm1.discoverfinancial.com:8443

Traceback (most recent call last):
  File "<pyshell#20>", line 1, in <module>
    execfile('C:\Users\idatta\Project\Python\Demo\JenkinsAPI_v1.py')
  File "C:\Users\idatta\Project\Python\Demo\JenkinsAPI_v1.py", line 28, in <module>
    print get_server_instance().version
  File "C:\Users\idatta\Project\Python\Demo\JenkinsAPI_v1.py", line 19, in get_server_instance
    server = Jenkins(jenkins_url, username = 'idatta', password = 'Gr33nCard_1', ssl_verify=False)
  File "C:\Python27\lib\site-packages\jenkinsapi\jenkins.py", line 59, in __init__
    JenkinsBase.__init__(self, baseurl, poll=not lazy)
  File "C:\Python27\lib\site-packages\jenkinsapi\jenkinsbase.py", line 35, in __init__
    self.poll()
  File "C:\Python27\lib\site-packages\jenkinsapi\jenkinsbase.py", line 61, in poll
    data['jobs'] = self.resolve_job_folders(data['jobs'])
  File "C:\Python27\lib\site-packages\jenkinsapi\jenkinsbase.py", line 100, in resolve_job_folders
    jobs += self.process_job_folder(job, self.baseurl)
  File "C:\Python27\lib\site-packages\jenkinsapi\jenkinsbase.py", line 112, in process_job_folder
    result += self.process_job_folder(job, folder_path)
  File "C:\Python27\lib\site-packages\jenkinsapi\jenkinsbase.py", line 112, in process_job_folder
    result += self.process_job_folder(job, folder_path)
  File "C:\Python27\lib\site-packages\jenkinsapi\jenkinsbase.py", line 107, in process_job_folder
    tree='jobs[name,color]')
  File "C:\Python27\lib\site-packages\jenkinsapi\jenkinsbase.py", line 79, in get_data
    response = requester.get_url(url, params)
  File "C:\Python27\lib\site-packages\jenkinsapi\utils\requester.py", line 109, in get_url
    return requests.get(self._update_url_scheme(url), **requestKwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 423, in send
    timeout=timeout
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 384, in _make_request
    httplib_response = conn.getresponse(buffering=True)
  File "C:\Python27\lib\httplib.py", line 1136, in getresponse
    response.begin()
  File "C:\Python27\lib\httplib.py", line 453, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\lib\httplib.py", line 409, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "C:\Python27\lib\socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
  File "C:\Python27\lib\ssl.py", line 756, in recv
    return self.read(buflen)
  File "C:\Python27\lib\ssl.py", line 643, in read
    v = self._sslobj.read(len)
KeyboardInterrupt
>>> 

Answer 1:

上的错误v = self._sslobj.read(len)意味着你打断而读正在进行中。 这似乎是完全没有证件,但jenkinsapi尝试下载每个作业的信息,它启动时,如果你的詹金斯回购是巨大的它会永远需要。 它可以设置为lazy = true,但它仍然会尝试加载所有作业当您试图访问一个单一的作业。 可能更好地使用一些其他的库。

server = Jenkins(jenkins_url, username = 'foouser', password = 'foopassword', lazy=True)


文章来源: Call to JenkinsAPI(https) just hangs