詹金斯(Jenkins)的“错误403错误请求中未包含有效碎屑". [英] Jenkins "Error 403 No valid crumb was included in the request"
问题描述
我正在尝试使用以下命令通过Windows计算机上的发布请求来触发Jenkins构建.
I am trying to trigger a Jenkins build by post request from my Windows computer, using the following commands.
首先,我使用...获得面包屑.
First, I obtain the crumb using...
curl http://JENKINS-URL/crumbIssuer/api/xml?xpath=//crumb
响应是这样的...
<crumb>string-of-digits<\crumb>
然后我使用命令
curl -u USERNAME:PASSWORD -X POST -H "Jenkins-Crumb:string-of-digits" http://JENKINS-URL/job/my-job/buildWithParameters?token=my-token
用户名正确,密码正确,面包屑恰好是我从第一个命令获得的数字字符串(开头的面包屑>和末尾的< \ crumb>之间的所有字符),令牌匹配我在詹金斯中指定的令牌.但是我仍然得到了回应
The username is correct, the password is correct, the crumb is exactly the string of digits that I got from the first command (everything between the crumb> at the beginning and <\crumb> at the end), the token matches the token I have specified in Jenkins. But still, I am getting the response
Error 403 No valid crumb was included in the request
在配置全局安全性-> CSRF保护"中,我还选中了启用代理兼容性",并且正在使用默认碎屑颁发者".
In Configure Global Security -> CSRF Protection, I also have "Enable proxy compatibility" checked and am using "Default Crumb Issuer".
看起来我在这里丢失了什么吗?忘记任何步骤了吗?格式不正确的命令?您还能想到什么?
Does it look like I am missing anything here? Forgetting any steps? Improperly formatted commands? Anything else you might be able to think of?
我已经按照步骤操作,并格式化了命令,就像这里的解决方案一样,仍然没有运气.
I have followed the steps and formatted my command like the solution here as well, and still no luck..
除此之外,我还尝试从第一个请求中保存cookie以获取面包屑,然后将保存cookie的文件传递到第二个curl命令中,有关该命令,请参见下文.还是我得到了403没有有效的面包屑...
In addition to this, I have also tried saving the cookies from the first request to get the crumb, and then I pass the file I saved the cookies to into the second curl command, see below for the command. Still I am getting the 403 No valid crumb...
以下是使用cookie的命令...
Here are the commands using cookies...
wget --keep-session-cookies --save-cookies cookies.txt --auth-no-challenge --user admin --password my_password -q --output-document - http://JENKINS-URL/crumbIssuer/api/xml?xpath=//crumb
curl --cookie cookies.txt -u admin:my_password -H "JenkinsCrumb: string-of-digits-from-stdout" -X POST http://JENKINS-URL/job/my-job/buildWithParameters?token=my-token
推荐答案
我终于找到了答案.我以为可以指定实际的帐户密码,但是事实证明,我需要可以使用API令牌进行身份验证.在上述命令中使用API令牌而不是密码和cookie可以使我远程触发构建.
I have finally discovered the answer. I thought that I could specify my actual account password, but it turns out that I needed to use an API token to authenticate. Using the API token instead of my password on the above commands with cookies allowed me to trigger my build remotely.
这篇关于詹金斯(Jenkins)的“错误403错误请求中未包含有效碎屑".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!