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.

  • Git Integration in RadStudio / Delphi 10
  • Is there any way to speed up git svn?
  • Delete-repository-hook for git repositories in Bitbucket Server
  • Unable to add, commit, push new files/directories to Git: working tree clean
  • Why won't my VSS2017 publish profiles show up as changes for pushing to source control
  • Free GIT Server with Web GUI a la BitBucket/GitHub
  • How to read git push arguments in hook?
  • How do I add libraries to my git repository but not track them?
  • Git rollback to previous checkout
  • Use git (windows) with a private key
  • How do I merge changes of one file into another across different repositories
  • Server side had nothing changed after I used “git push” successfully
  • One Solution collect form web for “Bitbucket server webhook to jenkins not posting after upgrade from stash”

    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.

    Git Baby is a git and github fan, let's start git clone.