使用python-jenkins时HTTP错误503服务不可用-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

使用python-jenkins时HTTP错误503服务不可用

我刚接触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来解决此问题

展开
收起
几许相思几点泪 2019-12-22 18:30:56 1325 0
1 条回答
写回答
取消 提交回答
  • HaydenGuo
    坚持这件事孤独又漫长。

    报错很明显了,你先单独访问下这个接口,看下有数据返回吗?还有可以从Jenkins的日志看下具体信息。

    http://10.1.nn.nnn:8080/crumbIssuer/api/json
    
    2022-11-30 16:08:26
    赞同 展开评论 打赏
问答排行榜
最热
最新
相关电子书
更多
给运维工程师的Python实战课
立即下载
Python 脚本速查手册
立即下载
ACE 区域技术发展峰会:Flink Python Table API入门及实践
立即下载