reconquest / atlassian-external-hooks

External Hooks plugin for Atlassian Bitbucket
https://external-hooks.reconquest.io
Other
45 stars 37 forks source link

External hooks suddenly stopped working - Hook script xxxx not found #135

Open thoro opened 1 year ago

thoro commented 1 year ago

Hello,

today our hook scripts suddenly stopped working. I traced it back to the "hook-scripts" folder being empty and needing to recreate it - I do not know how this might have happened.

remote: Hook script hook-scripts/1672/0 not foundexternal-pre-receive-hook failed
remote: The hook script could not be started.
remote:
remote: external-pre-receive-hook declined

/var/atlassian/bitbucket/shared/config/hook-scripts

was empty.

kovetskiy commented 1 year ago

Hey, that looks like a bug in Atlassian Bitbucket itself. The add-on doesn't remove files from such internal directory. Could you please check logs of the Bitbucket server?

thoro commented 1 year ago

Nothing in the logs, except before the issue the DB connection was down for a few hours.

Could a broken db connection cause this?

kovetskiy commented 1 year ago

That's difficult to say. I think the best option for you is to submit a support ticket to Atlassian, they will ask you to upload the support zip which you can obtain in your Bitbucket installation.

In the meantime, you can try to recreate hooks manually. You need to go to Triggers page, click on the checkbox Apply to existing hooks, and apply the triggers. Here is the doc: https://external-hooks.reconquest.io/docs/triggers/

Please let me know how it goes.

thoro commented 1 year ago

I was easily able to recreate them via reapplying the hook on the project, but maybe there could be a button in the UI - just in case this happens to someone else, that iterates over all hooks and recreates the hook file?

kovetskiy commented 1 year ago

The triggers page basically does exactly this, please let me know if the issue persists

thoro commented 1 year ago

It happened again today.

utking commented 1 year ago

We have the same issue. More often it happens when you push a new branch that does not exist on remote (in BitBucket) yet. It complains about the missing script the same way as in @Thoro 's example and does not really starts the existing hook script - we added debugging in our script and it had nothing in the output. It looks like the plugin (or BitBucket?) does not even try to created a cached version of the script to work with. We do not experience DB issues though. So the connection is not in play here. The recreation of the hook works only temporarily - after 1-2 days the very same error appears again and for the same repos.

PS - this can be the cause - https://jira.atlassian.com/browse/BSERV-13562

thoro commented 1 year ago

Seems to not happen that often, but happened again today.

Maybe the hook script could be recreated if it's missing? There's a java callback called before the hook script is executed, right?