【发布时间】:2021-04-22 12:30:00
【问题描述】:
我正在创建 webhook,任何来自 Bitbucket 的 git 推送都会触发 Jenkins 作业在 Linux 主机上运行(无需插件)。
在 jenkins 中,我创建了一个简单的管道,并提出了这个 webhook URL。
http://admin:apiToken@www.myjenkins.com:8080/job/job123/build?token=xxxxxx
我测试了在 CLI 上运行这个 webhook URL,它工作正常,我可以看到新作业在 Jenkins 门户中成功启动。
$ curl -s --show-error http://admin:apiToken@www.myjenkins.com:8080/job/job123/build?token=xxxxxx
但是,此 URL 在 Bitbucket 的 webhook 设置中不起作用 (project > repo > repo settings > webhooks )。我点击了“测试连接”,它返回了403,并带有以下错误响应
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
-->
我使用了admin 帐户,但它显示为“匿名”。
我还测试了git push,但 Jenkins 什么也没发生。
根据错误响应,看起来它与身份验证问题有关......但很奇怪,curl 的命令行工作正常。这意味着:
- 使用管理员令牌进行身份验证即可。
- 资源网址正确。
但在 Bitbucket 中同样不起作用。
最后,我测试了在 Jenkins 中启用匿名帐户,Bitbucket 可以触发构建到 Jenkins,但风险太大。 有人对我的问题有想法吗? 谢谢
【问题讨论】:
标签: git jenkins bitbucket webhooks bitbucket-webhook