我刚接触Python,并尝试使用python-jenkins来打印“ whoami”。我使用Python 3.6和Windows 10
import jenkins
server = jenkins.Jenkins('http://10.1.nn.nnn:8080')
uname = server.get_whoami()
并且错误并显示以下消息。我在日常活动中使用了上述网址
Traceback (most recent call last):
File "C:\Users\sathishkumar.kailas\AppData\Local\Programs\Python\Python36\lib\site-packages\jenkins\__init__.py", line 793, in get_whoami
'GET', self._build_url(WHOAMI_URL, locals())
File "C:\Users\sathishkumar.kailas\AppData\Local\Programs\Python\Python36\lib\site-packages\jenkins\__init__.py", line 556, in jenkins_open
return self.jenkins_request(req, add_crumb, resolve_auth).text
File "C:\Users\sathishkumar.kailas\AppData\Local\Programs\Python\Python36\lib\site-packages\jenkins\__init__.py", line 572, in jenkins_request
self.maybe_add_crumb(req)
File "C:\Users\sathishkumar.kailas\AppData\Local\Programs\Python\Python36\lib\site-packages\jenkins\__init__.py", line 370, in maybe_add_crumb
'GET', self._build_url(CRUMB_URL)), add_crumb=False)
File "C:\Users\sathishkumar.kailas\AppData\Local\Programs\Python\Python36\lib\site-packages\jenkins\__init__.py", line 556, in jenkins_open
return self.jenkins_request(req, add_crumb, resolve_auth).text
File "C:\Users\sathishkumar.kailas\AppData\Local\Programs\Python\Python36\lib\site-packages\jenkins\__init__.py", line 575, in jenkins_request
self._request(req))
File "C:\Users\sathishkumar.kailas\AppData\Local\Programs\Python\Python36\lib\site-packages\jenkins\__init__.py", line 535, in _response_handler
response.raise_for_status()
File "C:\Users\sathishkumar.kailas\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 503 Server Error: Service Unavailable for url: http://10.1.nn.nnn:8080/crumbIssuer/api/json
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"C:\Users\sathishkumar.kailas\AppData\Local\Programs\Python\Python36\lib\sitepackages\jenkins\__init__.py", line 804, in get_whoami
% self.server)
我用Google搜索,但无法获得正确的URL来解决此问题
报错很明显了,你先单独访问下这个接口,看下有数据返回吗?还有可以从Jenkins的日志看下具体信息。
http://10.1.nn.nnn:8080/crumbIssuer/api/json
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。