29

尝试从任何 REST 客户端触发 Jenkins 作业时出现以下错误

Authentication required

     <!-- You are authenticated as: anonymous
Groups that you are in:

Permission you need to have (but didn't):
hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
-->
    </body> </html>

从终端使用 curl 时触发请求

我正在使用以下语法

http://user:apiToken@jenkins.yourcompany.com/job/your_job/build?token=TOKEN [参考:https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients]

IE。curl -X POST http://user:apiToken@jenkins.yourcompany.com/job/your_job/build?token=TOKEN

4

7 回答 7

12

检查此“此构建已参数化”,从下拉列表中选择凭据参数。用这个

curl -X POST http://jenkins.rtcamp.com/job/Snapbox/buildWithParameters --user "username:password"

它解决了我的身份验证问题。

我希望它也能帮助其他人。

于 2015-08-03T14:48:05.970 回答
6

我的开发团队的配置设置是这样的,matrix-based security所以我必须找到我的组并授予我的组工作区访问权限。

1.Click on Manage Jenkins .   
2.Click on Configure Global Security .  
3.in matrix-based security change: 

Overall - Read   
Job - Build  
Job - Read   
Job - Workspace  

然后

    POST jobUrl/buildWithParameters HTTP/1.1
    Host: user:token
    Authorization: Basic dWdlbmxpazo4elhjdmJuTQ==
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded

    Branch=develop
于 2017-05-30T19:35:31.163 回答
5

为了我

https://user:password@jenkins.mycompany.org/job/job_name/build?token=my_token

https://jenkins.mycompany.org/configureSecurity

禁用 CORS

希望这有帮助

于 2017-04-14T16:16:35.210 回答
2

我提供了带有值的标头授权参数:BASIC base_64encoded(username:password),它工作正常。

授权基础 bmltbWljdjpqZX*********

于 2014-08-20T00:04:50.827 回答
2

尝试使用 -u 参数指定凭据:

curl -u user:apiToken -X POST http://jenkins.yourcompany.com/job/your_job/build?token=TOKEN

于 2014-08-19T23:18:54.430 回答
1

只需在全局安全选项中禁用“CSRF 保护”,因为这些 URL 不会发送发布数据标识。

于 2017-09-27T19:37:21.723 回答
0

焦点: 用户名:密码@

curl -u user:apiToken -X POST http://username:password@jenkins.yourcompany.com/job/your_job/build?key1=value1&key2=value2 ...
于 2020-11-09T09:14:25.337 回答