Question

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. ;-)

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top