当前位置:  开发笔记 > 编程语言 > 正文

Python jenkinsapi忽略证书

如何解决《Pythonjenkinsapi忽略证书》经验,为你挑选了1个好方法。

最近,我将詹金斯变成了https。这是我使用jenkinsapi的代码:

import jenkinsapi
from jenkinsapi.jenkins import Jenkins
from jenkinsapi.utils.requester import Requester
import requests
url = 'https://jenkinsd:443'
username = 'MyUser'
password = '123'
requests.packages.urllib3.disable_warnings()
jenkins = Jenkins(url, username, password)
jobs = jenkins.get_jobs()
for jobName in jobs:
    print(jobName)

我收到此错误:

requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)

我试过了:

jenkins = Jenkins(url, requester=Requester(username, password, baseurl=url, ssl_verify=False))

要么:

jenkins = jenkinsapi.jenkins.Jenkins(url, username, password, requester =Requester(username, password, ssl_verify=False))

我收到此错误:

File "D:\Python34\lib\site-packages\requests-2.7.0-py3.4.egg\requests\adapters.py", line 415, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061, None))

请咨询:)



1> Yehiel G..:

解决了..

詹金斯=詹金斯(URL,用户名,密码,ssl_verify = False)

纠正URL后:管理Jenkins>配置系统> Jenkins URL

jenkinsapi现在可以工作了。

https://github.com/pycontribs/jenkinsapi/blob/master/doc/source/ssl_certificate_verification

谢谢!

推荐阅读
依然-狠幸福
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有