4

According to the content of the gitlab-shell post-receive hook, it's deprecated.

#!/usr/bin/env ruby

# This file was placed here by GitLab.
# IT IS DEPRECATED NOW.
# All GitLab logic handled by update hook

But only for Gitlab specific logic or generally? Imho I should still be able to use it for e.g. my chiliproject post-receive hook that updates my repositories. Unfortunately I couldn't find anything specific in this regard, mostly due to the gitolite <> gitlab-shell transition in gitlab v5. I hope someone can shed some light on this…

[edit]

The post-receive hook was removed from gitlab-shell for v1.7.1. So the correct way is to either create a web-hook, modify carefully the update hook or watch the development of gitlab-shell more closely until custom hook support is implemented. ;-)

nietonfir
  • 4,797
  • 6
  • 31
  • 43
  • possible duplicate of [Custom post-receive file using GitLab](http://stackoverflow.com/questions/14317452/custom-post-receive-file-using-gitlab) – Ciro Santilli OurBigBook.com Dec 17 '14 at 07:58
  • Since GitLab 7.5.0 (Nov. 2014), this is now implemented (thank you Ciro Santilli for the heads up). See the update answer below. – VonC Dec 17 '14 at 08:28

1 Answers1

4

Update 2014:

Ciro Santilli points out in the comments and in "Custom post-receive file using GitLab" that there is now (GitLab not using gitolite anymore) a way to setup custom hooks (GitLab 7.5.0+, Nov. 2014).

  1. Pick a project that needs a custom git hook.
  2. On the GitLab server, navigate to the project's repository directory.
    For a manual install the path is usually /home/git/repositories/<group>/<project>.git.
    For Omnibus installs the path is usually /var/opt/gitlab/git-data/repositories/<group>/<project>.git.
  3. Create a new directory in this location called custom_hooks.
  4. Inside the custom_hooks directory, create a file with a name matching the hook type.
    For a pre-receive hook the file name should be pre-receive with no extension.
  5. Make the hook file executable and make sure it's owned by git.
  6. Write the code to make the git hook function as expected. Hooks can be in any language. Ensure the 'shebang' at the top properly reflects the language type.
    For example, if the script is in Ruby the shebang will probably be #!/usr/bin/env ruby.

Original answer (Apr. 2013)

That is a direct consequence of not using gitolite, and replacing it with gitlab-shell with GitLab5.x.

That is why you have gitlab-shell Issue 14, about allowing custom update hooks.

For now, you would add to register that hook yourself for each repos on the Gitlab server, which isn't very convenient.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I see. And thanks for the link to the issue, must've read over it. But what is there against using `post-receive` the way it's intended by git (as gitlab isn't using it anymore obviously)? – nietonfir Apr 27 '13 at 21:01
  • @nietonfir `update` or `post-update` hooks... in either case, you would need to register them manually to the right repos, while gitolite was doing it for you before. Issue 14 is about restoring that feature. – VonC Apr 27 '13 at 21:11
  • I think that issue might have been implemented. Answered on possible duplicate question: http://stackoverflow.com/a/27520784/895245 – Ciro Santilli OurBigBook.com Dec 17 '14 at 08:02
  • @CiroSantilli thank you. I have updated the answer accordingly. – VonC Dec 17 '14 at 08:27