- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
长话短说
Jenkins 告诉我在从 Ansible 脚本安装插件时传递了一个无效的 crumb 值
详情
我使用官方 Docker 容器在 Docker 容器中运行 Jenkins 2.32.2。
我已将它安装到 Vagrant VM,并尝试使用 Ansible 配置插件。
我正在使用以下任务遍历插件列表
- name: Install plugins
include: install_plugin.yml
with_items: "{{ plugins }}"
loop_control:
loop_var: plugin_name
tags: [jenkins]
在 defaults/main.yml 文件中定义了以下列表
plugins:
- git
- template-project
- pipeline
- docker-workflow
- template-project
- config-file-provider
- bitbucket
- disk-usage
- greenballs
- jacoco
- slack
- sonar
下面是从main.yml文件调用的install_plugin.yml的定义
---
- name: Get Jenkins crumb
uri:
user: admin
password: "{{ jenkins_admin_password }}"
force_basic_auth: yes
url: "http://{{ ansible_hostname }}:8080/crumbIssuer/api/json"
return_content: yes
register: crumb_token
until: crumb_token.content.find('Please wait while Jenkins is getting ready') == -1
retries: 10
delay: 5
tags: [jenkins]
- name: Plugins are installed
uri:
url: "http://{{ ansible_host }}:8080/pluginManager/installNecessaryPlugins"
method: POST
user: admin
password: "{{ jenkins_admin_password }}"
body: '<jenkins><install plugin="{{ plugin_name }}@latest" /></jenkins>'
headers:
Content-Type: "text/xml"
Jenkins-Crumb: "{{ crumb_token.json.crumb }}"
creates: "{{ jenkins_home }}/plugins/{{ plugin_name }}"
register: plugins_result
tags: [jenkins]
- wait_for:
path: "{{ jenkins_home }}/plugins/{{ plugin_name }}"
tags: [jenkins]
当我尝试在命令行中使用 curl 模拟此操作时,我使用以下 2 个命令获得了预期的结果,它成功运行
~/Projects/ci> curl --user admin:admin cluster01:8080/crumbIssuer/api/json
{"_class":"hudson.security.csrf.DefaultCrumbIssuer","crumb":"646966a811fe84bdc5dc00a0de942b80","crumbRequestField":"Jenkins-Crumb"}%
~/Projects/ci> curl -X POST --user admin:admin -d '<jenkins><install plugin="git@latest" /></jenkins>' --header 'Jenkins-Crumb: 646966a811fe84bdc5dc00a0de942b80' --header 'Content-Type: text/xml' http://cluster01:8080/pluginManager/installNecessaryPlugins
但是当我运行 Ansible 剧本时,出现以下错误
status code was not [200]: HTTP Error 403: No valid crumb was included in the request
这是此步骤的 -vvvv 的日志输出
TASK [jenkins : Install plugins] ***********************************************
task path: /Users/chris/Projects/ci/roles/jenkins/tasks/main.yml:56
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
TASK [jenkins : Get Jenkins crumb] *********************************************
task path: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml:2
Using module file /usr/local/Cellar/ansible/2.2.0.0_2/libexec/lib/python2.7/site-packages/ansible/modules/core/network/basics/uri.py
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r cluster01 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555 `" && echo ansible-tmp-1486148016.3-32614286575555="` echo $HOME/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555 `" ) && sleep 0'"'"''
<cluster01> PUT /var/folders/g5/h48p994d3qn7d9_nz7xv2lvh0000gn/T/tmprL_Pye TO /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/uri.py
<cluster01> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r '[cluster01]'
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r cluster01 '/bin/sh -c '"'"'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/ /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/uri.py && sleep 0'"'"''
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r -tt cluster01 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-vzqwuvcglpsfrrzkvwdcupjtukijcwvl; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/uri.py; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
ok: [cluster01] => {
"attempts": 1,
"changed": false,
"connection": "close",
"content": "{\"_class\":\"hudson.security.csrf.DefaultCrumbIssuer\",\"crumb\":\"ad67abc734af7eae279df5c68098a29e\",\"crumbRequestField\":\"Jenkins-Crumb\"}",
"content_type": "application/json;charset=UTF-8",
"date": "Fri, 03 Feb 2017 18:53:36 GMT",
"invocation": {
"module_args": {
"backup": null,
"body": null,
"body_format": "raw",
"content": null,
"creates": null,
"delimiter": null,
"dest": null,
"directory_mode": null,
"follow": false,
"follow_redirects": "safe",
"force": false,
"force_basic_auth": true,
"group": null,
"headers": {
"Authorization": "Basic YWRtaW46YWRtaW4="
},
"http_agent": "ansible-httpget",
"method": "GET",
"mode": null,
"owner": null,
"password": "admin",
"regexp": null,
"remote_src": null,
"removes": null,
"return_content": true,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"status_code": [
200
],
"timeout": 30,
"unsafe_writes": null,
"url": "http://cluster01:8080/crumbIssuer/api/json",
"url_password": "admin",
"url_username": "admin",
"use_proxy": true,
"user": "admin",
"validate_certs": true
},
"module_name": "uri"
},
"json": {
"_class": "hudson.security.csrf.DefaultCrumbIssuer",
"crumb": "ad67abc734af7eae279df5c68098a29e",
"crumbRequestField": "Jenkins-Crumb"
},
"msg": "OK (unknown bytes)",
"redirected": false,
"server": "Jetty(9.2.z-SNAPSHOT)",
"status": 200,
"url": "http://cluster01:8080/crumbIssuer/api/json",
"x_content_type_options": "nosniff",
"x_jenkins": "2.32.2",
"x_jenkins_session": "3abb7e45"
}
TASK [jenkins : Plugins are installed] *****************************************
task path: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml:15
Using module file /usr/local/Cellar/ansible/2.2.0.0_2/libexec/lib/python2.7/site-packages/ansible/modules/core/network/basics/uri.py
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r cluster01 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735 `" && echo ansible-tmp-1486148016.66-148559593691735="` echo $HOME/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735 `" ) && sleep 0'"'"''
<cluster01> PUT /var/folders/g5/h48p994d3qn7d9_nz7xv2lvh0000gn/T/tmp1RWIY4 TO /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735/uri.py
<cluster01> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r '[cluster01]'
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r cluster01 '/bin/sh -c '"'"'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735/ /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735/uri.py && sleep 0'"'"''
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r -tt cluster01 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-qixxmffrdktqhuyukutskswbxfsaxrdd; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735/uri.py; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
fatal: [cluster01]: FAILED! => {
"cache_control": "must-revalidate,no-cache,no-store",
"changed": false,
"connection": "close",
"content": "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<title>Error 403 No valid crumb was included in the request</title>\n</head>\n<body><h2>HTTP ERROR 403</h2>\n<p>Problem accessing /pluginManager/installNecessaryPlugins. Reason:\n<pre> No valid crumb was included in the request</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>\n\n</body>\n</html>\n",
"content_length": "387",
"content_type": "text/html; charset=ISO-8859-1",
"date": "Fri, 03 Feb 2017 18:53:37 GMT",
"failed": true,
"invocation": {
"module_args": {
"backup": null,
"body": "<jenkins><install plugin=\"git@latest\" /></jenkins>",
"body_format": "raw",
"content": null,
"creates": "/var/jenkins_home/plugins/git",
"delimiter": null,
"dest": null,
"directory_mode": null,
"follow": false,
"follow_redirects": "safe",
"force": false,
"force_basic_auth": false,
"group": null,
"headers": {
"Content-Type": "text/xml",
"Jenkins-Crumb": "ad67abc734af7eae279df5c68098a29e"
},
"http_agent": "ansible-httpget",
"method": "POST",
"mode": null,
"owner": null,
"password": "admin",
"regexp": null,
"remote_src": null,
"removes": null,
"return_content": false,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"status_code": [
200
],
"timeout": 30,
"unsafe_writes": null,
"url": "http://cluster01:8080/pluginManager/installNecessaryPlugins",
"url_password": "admin",
"url_username": "admin",
"use_proxy": true,
"user": "admin",
"validate_certs": true
},
"module_name": "uri"
},
"msg": "Status code was not [200]: HTTP Error 403: No valid crumb was included in the request",
"redirected": false,
"server": "Jetty(9.2.z-SNAPSHOT)",
"status": 403,
"url": "http://cluster01:8080/pluginManager/installNecessaryPlugins",
"x_content_type_options": "nosniff"
}
我已将整个构建(Vagrant 和 Ansible)推送到 github
最佳答案
我也遇到了这个问题,发现您需要在安装插件的 uri
任务中指定 force_basic_auth: True
。我看到你在注册 crumb_token
变量(name: Get Jenkins crumb
)的任务中有它,所以你只需要将它添加到 name 中:插件已安装
任务。
关于jenkins - 使用 Ansible 安装 Jenkins 插件告诉我面包屑值无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42031442/
我想创建一个 Jenkins 工作来启动其他 Jenkins 工作。这很容易,因为 Jenkins 模板项目插件允许我们创建“使用另一个项目的构建器”类型的构建步骤。然而,让我的情况更难的是我必须在其
我有一个简单的Windows批处理命令(robocopy),该命令返回零错误,但在Jenkins中始终被标记为失败。我想知道为什么? D:\ Jenkins \ jobs \ Jenkins Conf
我有两个 Jenkins 工作 - Jenkins Job1 和 Jenkins Job2。 我有多个应用程序并使用相同的 Jenkins 来构建应用程序。如果相同的应用程序在 Jenkins 中运行
我找不到这两者之间的区别。这些是相同的还是不同的。 最佳答案 第一个区别是支持(正如其他人所提到的)。 CloudBees 提供企业级支持以及经过全面审查和测试的 Jenkins 版本,该版本将在各种
是否可以指定在多次触发作业(A)的情况下,将先前的作业从队列中删除,并且如果有足够的可用插槽,则仅将最新的作业留在队列中或启动? 提前致谢! 最佳答案 您可以使用通过Groovy Script Plu
我有2位Jenkins主持人,并且希望First Jenkins在第一个结果的基础上基于“SUCCESS”触发远程Jenkins上的工作。 我看过各种插件,但它们似乎都表明一个Jenkins主机,可以
我的 jenkinsfile 有几个参数,每次我更新参数(例如删除或添加新输入)并将更改提交到我的 SCM 时,我没有在 jenkins 中看到相应更新的作业输入屏幕,我必须运行执行,取消它,然后查看
有没有办法在构建完成后触发相同的工作。我有一项工作需要运行,直到我手动中止它。有没有办法做到这一点? 最佳答案 最简单的方法是添加一个构建相同项目的后期构建步骤。将“构建后操作”-“构建其他项目”-“
我在 Linux 家中的特定用户下有工作/.jenkins 文件夹。我想与另一个用户一起启动 Jenkins,但重新使用另一个用户的 .jenkins 文件夹。我怎样才能做到这一点? Jenkins
我是 Jenkins 的新手,我不确定这是否可行,但我想设置一个 Web 界面,人们可以在其中单击“开始作业”,这将告诉 Jenkins 开始特定的构建作业。 Jenkins 是否有允许此类操作的网络
如何获取 Jenkins 凭证变量,即“mysqlpassword”,可供 Jenkins 声明性管道的所有阶段访问? 下面的代码片段工作正常并打印我的凭据。 node { stage('Gett
如何获取 Jenkins 凭证变量,即“mysqlpassword”,可供 Jenkins 声明性管道的所有阶段访问? 下面的代码片段工作正常并打印我的凭据。 node { stage('Gett
如何将构建参数从一个项目传递到另一个项目? 我们在 Jenkins 用户界面中是否有任何配置,可以在完成一个构建项目后将构建参数传递给另一个项目? 我能够触发另一个项目,但无法传递构建参数。我们是否有
我正在 Jenkins 中构建一个项目,并希望在它之后立即启动测试,请稍候 直到测试完成,然后运行另一个作业来分析结果。测试系统是一个封闭的系统(我不能修改它)所以为了检查测试是否完成我需要每 X 秒
我创建了一个测试 jenkins 作业管道。此作业具有字符串参数 - 'testVar' Jenkins文件代码: println("env.TESTVAR=" + env.TESTVAR) prin
我的 Jenkins 工作“构建”配置有 3 执行 shell - 构建任务 2 构建后操作 有没有办法获取每个构建任务和构建后操作的运行时间? 最佳答案 不直接,这就是为什么: 我使用 a Jenk
是否有任何适用于 Jenkins 的插件可以为 Jenkins 提供键值存储选项?功能接近的插件是凭据插件。目标是拥有一个存储全局配置参数的插件,并且此参数可用于 Jenkins 作业。 最佳答案 转
默认情况下,Jenkins 是否会保留每个构建中生成的所有构建和工件。或者它会在一段时间后删除它们。我知道我可以配置“丢弃旧版本”选项,但我想知道 Jenkins 的默认行为。 最佳答案 默认是保留所
Jenkins 构建中的每个文件参数“帮助文本”, Accepts a file submission from a browser as a build parameter. The uploade
情况:我在我的虚拟服务器上安装了 Jenkins 并设置了一个“自由式管道”。我通过 webhook push 将它连接到我的 github,它可以工作(当我推送到存储库时,在 jenkins 中启动
我是一名优秀的程序员,十分优秀!