简体   繁体   English

从存储升级后,Bitbucket服务器Webhook到jenkins无法发布

[英]Bitbucket server webhook to jenkins not posting after upgrade from stash

We recently upgraded from Atlassian Stash 2.x to Atlassian Bitbucket Server 4.6.1. 我们最近从Atlassian Stash 2.x升级到Atlassian Bitbucket Server 4.6.1。 A lot of the post-commit hooks simply didn't work anymore because their plugins hadn't been updated, but one, the Bitbucket Server Webhook for Jenkins isn't firing after a commit. 许多提交后的钩子不再起作用,因为它们的插件尚未更新,但是其中一个, JenkinsBitbucket Server Webhook在提交后没有触发。 The hook works when I hit the "Trigger Jenkins" button in its configuration window, but it's not firing after a new commit gets pushed. 当我在其配置窗口中单击“ Trigger Jenkins”按钮时,该钩子起作用了,但是在推送了新的提交后,它并没有触发。

I had to do some digging. 我不得不做一些挖掘。 First, I turned on Bitbucket Server debug loggin via the UI . 首先,我通过UI启用Bitbucket Server调试登录 At that point, I saw some errors in the logs that pointed me to an article about git hooks not firing . 那时,我在日志中看到一些错误,这些错误使我引向一篇有关git hooks not firing的文章

From there, I went digging in my bitbucket_home directory for the missing scripts and their file permissions. 从那里,我在bitbucket_home目录中寻找丢失的脚本及其文件权限。 While I didn't find the 20_bitbucket_callback script, I did find a 20_stash_callback script in the same directory! 虽然我没有找到20_bitbucket_callback脚本,但在同一目录中确实找到了20_stash_callback脚本!

The article suggested checking their file permissions on the server, so I did. 这篇文章建议检查他们在服务器上的文件权限,所以我做了。

find . -name 20_stash_callback -printf "%p: %u:%g %m\\n" find . -name pre-receive -printf "%p: %u:%g %m\\n" find . -name post-receive -printf "%p: %u:%g %m\\n"

Lo and behold, all the scripts had the permissions 644, or "Read/write for root, read-only for everyone else." 瞧,所有脚本的权限均为644,或者“对于root用户是读/写的,对其他所有人都是只读的”。 I changed that with a little find ... -exec . 我通过一点find ... -exec改变了它。

sudo -u someuser find . -name 20_stash_callback -type f -exec chmod 774 {} \\; sudo -u someuser find . -name post-receive -type f -exec chmod 774 {} \\; sudo -u someuser find . -name pre-receive -type f -exec chmod 774 {} \\;

I still wasn't seeing my jenkins builds fire, when it occurred to me that I might need to rename the callback script to the one described in the documention. 当我想到可能需要将回调脚本重命名为文档中描述的脚本时,我仍然没有看到我的詹金斯大火。

sudo -u someuser find . -name 20_stash_callback -type f -exec rename 20_stash_callback 20_bitbucket_callback {} \;

After that, my the hook worked! 之后,我的钩子起作用了! And there was much rejoicing. 有很多的欣喜。

Note that the someuser account used above is the local user that our stash instance runs under. 请注意,上面使用的someuser帐户是我们的隐藏实例在其下运行的本地用户。 Make sure to change that for your needs if you use the above scripts. 如果使用上述脚本,请确保根据您的需要进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM