2

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>

認証が成功し、ビューが作成され、構成ページにリダイレクト (HTTP 302) されたことがわかりますが、間違ったパスワード エラーで失敗しました。

実行後、新しく作成されたビューが表示され、スクリプトを再度実行するとビューが見つかり、次のビューが作成され、同じエラーで再び失敗します。問題は、そのようなビューが多数必要なことです。

誰か助けてくれたり、問題を指摘してくれませんか? 前もって感謝します。

4

1 に答える 1