简体   繁体   中英

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. 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. 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.

I had to do some digging. First, I turned on Bitbucket Server debug loggin via the UI . At that point, I saw some errors in the logs that pointed me to an article about git hooks not firing .

From there, I went digging in my bitbucket_home directory for the missing scripts and their file permissions. While I didn't find the 20_bitbucket_callback script, I did find a 20_stash_callback script in the same directory!

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." I changed that with a little 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. Make sure to change that for your needs if you use the above scripts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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