【发布时间】:2022-12-02 03:55:01
【问题描述】:
I have been using the Python Jenkins apis to manager my Jeninks jobs. it ahs worked for a long time, but it stopped suddenly working. This is the code excerpt: import jenkins
server = jenkins.Jenkins('https://jenkins.company.com', username='xxxx', password='password')
server._session.verify = False
print(server.jobs_count())
the traceback:
File "", line 1, in server.jobs_count()
File "E:\anaconda3\Lib\site-packages\jenkins_init_.py", line 1160, in jobs_count return len(self.get_all_jobs())
File "E:\anaconda3\Lib\site-packages\jenkins_init_.py", line 1020, in get_all_jobs jobs = [(0, [], self.get_info(query=jobs_query)['jobs'])]
File "E:\anaconda3\Lib\site-packages\jenkins_init_.py", line 769, in get_info requests.Request('GET', self._build_url(url))
File "E:\anaconda3\Lib\site-packages\jenkins_init_.py", line 557, in jenkins_open return self.jenkins_request(req, add_crumb, resolve_auth).text
File "E:\anaconda3\Lib\site-packages\jenkins_init_.py", line 573, in jenkins_request self.maybe_add_crumb(req)
File "E:\anaconda3\Lib\site-packages\jenkins_init_.py", line 371, in maybe_add_crumb 'GET', self._build_url(CRUMB_URL)), add_crumb=False)
File "E:\anaconda3\Lib\site-packages\jenkins_init_.py", line 557, in jenkins_open return self.jenkins_request(req, add_crumb, resolve_auth).text
File "E:\anaconda3\Lib\site-packages\jenkins_init_.py", line 576, in jenkins_request self._request(req))
File "E:\anaconda3\Lib\site-packages\jenkins_init_.py", line 550, in _request return self._session.send(r, **_settings)
File "E:\anaconda3\Lib\site-packages\requests\sessions.py", line 622, in send r = adapter.send(request, **kwargs)
File "E:\anaconda3\Lib\site-packages\requests\adapters.py", line 507, in send raise ProxyError(e, request=request)
ProxyError: HTTPSConnectionPool(host='ebs.usps.gov', port=443): Max retries exceeded with url: /job/scp/job/sm/job/9218/job/4198/job/SIT/crumbIssuer/api/json (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden')))
Note that there is no proxy on the Jenkins server, and I can use the user/password logon to the Jenkins server with no issues.
I have the crum id and API token, but I haven't found anything that indicating how to add the crum into the Python-Jenkins api.
Appreciate any suggestion
【问题讨论】:
-
Setting
verifyto False appears to be irrelevant. It's a cert check, and you don't even get far enough in the protocol to learn any server cert details. -
this is a test, shortest code snip that points to the issue, and generate the exact trace, yes, the cert line has nothing to do with the issue