Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法使用jenkinsapi在Jenkins中创建视图_Python_Jenkins_Jenkins Cli - Fatal编程技术网

Python 无法使用jenkinsapi在Jenkins中创建视图

Python 无法使用jenkinsapi在Jenkins中创建视图,python,jenkins,jenkins-cli,Python,Jenkins,Jenkins Cli,我正在尝试使用Python和jenkinsapi在Jenkins中创建一组嵌套视图 代码如下: jenkins_url = "http://127.0.0.1:8080/" api = Jenkins(jenkins_url, 'jenkins_admin', 'jenkins_password') logger.info('view_name is %s' %view_name) new_view = api.views.create(view_name, Views.NESTED_VIEW)

我正在尝试使用Python和jenkinsapi在Jenkins中创建一组嵌套视图

代码如下:

jenkins_url = "http://127.0.0.1:8080/"
api = Jenkins(jenkins_url, 'jenkins_admin', 'jenkins_password')
logger.info('view_name is %s' %view_name)
new_view = api.views.create(view_name, Views.NESTED_VIEW)
如果我禁用授权并允许“任何人都可以做任何事情”,但用户/密码身份验证失败,那么一切都会顺利进行。我们正在使用Active Directory,用户具有管理权限

失败是:

INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:"GET /api/python **HTTP/1.1" 200 3290**
INFO:root: view_name is 9.8
INFO:jenkinsapi.views:Creating "hudson.plugins.nested_view.NestedView" view "9.8"
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:"POST /createView **HTTP/1.1" 302 0**
DEBUG:requests.packages.urllib3.connectionpool:"GET /view/9.8/configure **HTTP/1.1" 401 1445**
Traceback (most recent call last):
  File "JenkinsNewVersionJobsItems.py", line 46, in <module>
    top_view = NewVersionJobsItemsUtils.createView(short_version, api, NESTED)
  File "/tmp/NewVersionJobsItemsUtils.py", line 35, in createView
    new_view = parent_view.views.create(view_name, Views.NESTED_VIEW)
  File "build/bdist.linux-x86_64/egg/jenkinsapi/views.py", line 103, in create
  File "build/bdist.linux-x86_64/egg/jenkinsapi/utils/requester.py", line 117, in post_and_confirm_status
jenkinsapi.custom_exceptions.JenkinsAPIException: Operation failed. url=http://127.0.0.1/view/9.8/configure, data={'json': '{"name": "9.8", "mode": "hudson.plugins.nested_view.NestedView"}', 'name': '9.8', 'Submit': 'OK', 'mode': 'hudson.plugins.nested_view.NestedView'}, headers={'Content-Type': 'application/x-www-form-urlencoded'}, status=401, text=<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>**Error 401 Invalid password/token for user: jenkins**</title>
</head>
<body><h2>HTTP ERROR 401</h2>
INFO:requests.packages.urllib3.connectionpool:启动新的HTTP连接(1):127.0.0.1
调试:requests.packages.urllib3.connectionpool:“GET/api/python**HTTP/1.1”200 3290**
信息:root:view\u名称为9.8
信息:jenkinsapi.view:创建“hudson.plugins.nested_view.NestedView”视图“9.8”
信息:requests.packages.urllib3.connectionpool:启动新的HTTP连接(1):127.0.0.1
调试:requests.packages.urllib3.connectionpool:“POST/createView**HTTP/1.1”302 0**
调试:requests.packages.urllib3.connectionpool:“GET/view/9.8/configure**HTTP/1.1”401 1445**
回溯(最近一次呼叫最后一次):
文件“JenkinsNewVersionJobsItems.py”,第46行,在
top\u view=NewVersionJobsItemsUtils.createView(短版本,api,嵌套)
createView中第35行的文件“/tmp/NewVersionJobsItemsUtils.py”
新建视图=父视图。视图。创建(视图名称,视图。嵌套视图)
文件“build/bdist.linux-x86_64/egg/jenkinsapi/views.py”,第103行,在create中
文件“build/bdist.linux-x86_64/egg/jenkinsapi/utils/requester.py”,第117行,处于post_和确认_状态
jenkinsapi.custom_exceptions.jenkinsapi异常:操作失败。网址=http://127.0.0.1/view/9.8/configure,数据={'json':{“名称”:“9.8”,“模式”:“hudson.plugins.nested_-view.NestedView”}”,“名称”:“9.8”,“提交”:“确定”,“模式”:“hudson.plugins.nested_-view.NestedView”},标题={'Content-Type':'application/x-www-form-urlencoded'},状态=401,文本=
**错误401用户的密码/令牌无效:jenkins**
HTTP错误401
我看到身份验证通过了,视图被创建了,我被重定向(HTTP 302)到它的配置页面,但由于密码错误而失败

执行后,我可以看到新创建的视图,再次运行脚本会找到该视图,创建下一个视图,并再次失败,出现相同的错误。问题是我需要一打这样的观点

有人能帮我解决这个问题吗?
提前感谢。

如果您尝试创建嵌套视图,但未安装嵌套视图插件,则会出现这种行为。也许这是您的问题?

您好,这里是jenkinsapi维护人员。您介意在Github()上打开一个问题吗?还请提供您的真实代码,而不仅仅是创建俯视图的代码。我无法重现这个问题。