7

I use GitLab Community Edition 8.2 and want to add post-commit hook.

I created file path_to_project.git/custom_hooks/post-commit with rights

$ ls -l1 custom_hooks/post-commit
-rwxr-xr-x 1 git git 45 Dec 14 21:31 custom_hooks/post-commit

and content

#!/bin/bash
echo "test custom" > /tmp/hook

as described here: http://doc.gitlab.com/ce/hooks/custom_hooks.html

But it not work (check by commiting via web interface). I tried also 'normal' git hook placement (project.git/hooks/post-commit), but it not work also.

8
+50

post-commit is a client-side hook and you can not implement it on server.

According to Gitlab documentation: http://doc.gitlab.com/ce/hooks/custom_hooks.html, you can implement a server-side custom hook (pre-receive, post-receive, and update) at the server.

Examples of server-side git hooks include pre-receive, post-receive, and update. See Git SCM Server-Side Hooks for more information about each hook type.

If you want to customize a client-side hook, you will need to change the original hook code or put your custom script at client under .git/hooks. Read more here: What are Git hooks?

And here is all about custom hooks: Customizing Git - Git Hooks

  • Yes, I tried to put that hook to .git/hooks (where is post-receive, pre-receive and update hooks located). Nothing changed. – strangeman Dec 17 '15 at 11:20
  • 2
    Well, please read again the differences between client-side and server-side hooks. The documentation is about server-side hooks. Those are located at server under ... gitlab-shell/hooks. Check this: gitlab.com/gitlab-org/gitlab-ce/issues/1742 – Diamant Dec 17 '15 at 11:26
  • Ohhh. I'm stupid. :( Sorry for inattentive read. All working as expected with post-receive hook, post-commit isn't work on server side, you're right. – strangeman Dec 17 '15 at 11:45
  • Glad that you could sort it out :) – Diamant Dec 17 '15 at 11:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.