Jenkins:获取配置时出现HTTP错误403

2024-05-29 11:44:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图以编程方式更新Jenkins jobs的配置,python Jenkins api看起来没问题,但由于HTTP错误403(禁止),我无法检索配置:

from jenkinsapi import api
j = api.Jenkins('https://server.test.com/hudson', 'fp12210', 'xxxxxxxx')
job = j.get_job('BBB-100-CheckStatusAll')
conf = job.get_config()

Traceback (most recent call last):
  ...
  File "C:\Python27\lib\urllib2.py", line 521, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden

在URL as mentionned in another SO post中添加用户和密码也失败:

 j = api.Jenkins('https://fp12210:xxxxxxxx@server.test.com/hudson')

Traceback (most recent call last):
  ...
  File "build\bdist.win32\egg\jenkinsapi\utils\retry.py", line 39, in retry_function
    raise e
InvalidURL: nonnumeric port: 'xxxxxxxx@server.test.com/hudson'

你知道吗?


Tags: inhttpstestcomapihttpgetserver
2条回答

这个SO post就是解决方案。我现在得到一个错误500,但这是另一个故事。。。

python jenkins api使用urllib2

您可以看到这样的答案:https://stackoverflow.com/a/24048578/1733117用于使用抢占式基本身份验证,或者在获得403时使用基本身份验证重试(例如,匿名用户具有有限的访问权限)。

相关问题 更多 >

    热门问题