Repository hooks won't execute after server migration

I recently moved a Bitbucket Server instance to a new machine using the supported process (which actually went perfectly, rather impressed!) from a Windows machine to a Linux one.

After migrating the repositories the execute permissions were not set on the hooks in the BITBUCKET_HOME\shared\data\repositories\xx\hooks\ directory, which I have updated as per this article but they are still throwing the error:

2017-10-10 17:24:06,581 WARN  [ssh-scm-request-handler] andrew@example.com @@VJPR66x1044x4763x0 1n4f9dv 10.xx.xx.xx SSH - git-receive-pack '/prj/deploytest.git' c.a.s.i.s.g.p.ssh.SshReceivePack PRJ/deploy-test[28]: Git hooks have not been called. Please verify that the hooks are configured correctly - see https://confluence.atlassian.com/display/BITBUCKETSERVERKB/Git+hook+scripts+are+not+executing?utm_campaign=in-app-help&utm_medium=in-app-help&utm_source=stash for detail

If I create a new repository from scratch the hooks work fine, but for older repositories that I have added the execute permission on they will not trigger.

I have gathered the support bundle zip and I notice that for the newly created repository it shows

<repository-hooks>
<hook>
<key>com.atlassian.stash.plugin.stash-web-post-receive-hooks-plugin:postReceiveHook</key>
<config>true</config>
</hook>
</repository-hooks>
<git-hooks>
<hook>
<name>pre-receive</name>
<size>430 B</size>
<executable>true</executable>
<callbacks>
<callback>
<name>20_bitbucket_callback</name>
<size>416 B</size>
<executable>true</executable>
</callback>
</callbacks>
</hook>
<hook>
<name>post-receive</name>
<size>432 B</size>
<executable>true</executable>
<callbacks>
<callback>
<name>20_bitbucket_callback</name>
<size>418 B</size>
<executable>true</executable>
</callback>
</callbacks>
</hook>
</git-hooks>

While the affected repository shows:

<git-hooks>
<hook>
<name>pre-receive</name>
<size>430 B</size>
<executable>true</executable>
<callbacks>None</callbacks>
</hook>
<hook>
<name>post-receive</name>
<size>432 B</size>
<executable>true</executable>
<callbacks>None</callbacks>
</hook>
</git-hooks>

So the callbacks are set to None, despite the fact that the 20_bitbucket_callback files are present under both pre-receive and post-receive.

Is there any way that I can get the repository to pick up the callbacks value again?

1 answer

1 accepted

After a great deal of tinkering around, I tried coping the template hooks files from $BITBUCKET_HOME/shared/config/git/templates/hooks/ into the hooks directory of the repository and setting the ownership to atlbitbucket.

Since then, hooks have started working on this repository despite having the same contents and permissions as the old files. I suspect this may have been a character-encoding related issue between Windows and Linux, though it may well just be a mystery.

In any case, I have answered my own question!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

22,881 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you