问题
We have Gitlab installed on the same server as a dev/staging copy of our test project. Two of us have local working copies with Gitlab as a remote, and are able to push/pull to Gitlab successfully. We also have Gitlab set as a remote in the staging copy of the project, and pulling from Gitlab works there manually as well.
However, when creating a custom hook for Gitlab (as described here), the hook simply fails to run with no errors. The content of the hook is:
#!/bin/bash
echo "Inside post_receive hook"
cd /path/to/staging/copy
git pull gitlab master
...where /path/to/staging/copy
is the staging location of the project. Here's the ownership & permissions of the hook:
-rwxr-xr-x. 1 git git 114 Mar 30 10:28 post_receive
When pushing from my working copy to Gitlab, this hook should run, but it doesn't -- the staging copy is not updated, the echo message isn't shown, and the push results message doesn't show any errors.
I have tried a few tips from SO answers regarding setting/unsetting environment variables, and they didn't help. I'm out of ideas. Does anyone know why the custom hook isn't running?
回答1:
Of course, this was my fault. I mis-named the hook with an underscore instead of a dash. Hook now fires appropriately.
来源:https://stackoverflow.com/questions/29350152/gitlab-custom-hook-not-running