How to add a server-side pre-receive hook in GitLab?

I am trying to limit the binary (exe, dll, pdf) committing in our gitlab. Therefore, I need to add a hook to limit it globally. How can i do this? Is the receiving hook suitable for this?

Is this the right place to add a hook?

/ Opt / gitlab / built-in / service / gitlab-shell / hooks / pre-receive

Any help appreciated!

+2
git gitlab githooks
source share
2 answers

As I said before, use custom interceptors for each project: ( Chaining support )
See the exact steps in How to add hooks to gitlab? "and enable repo.git/custom_hooks .

But this is for each repository, and not for all repositories.
You will need to add that script for each repo group.

pre-receive script that you see in the regular repo.git/hooks folder is actually a symbolic link to the gitlab-shell hook folder, and GitLab is used to control permissions.

0
source share

You can install a side hook, but it is not very well documented. Gitlab is currently integrating gitlab-shell and gitaly . Thus, providing instructions is a slightly moving goal, but they are valid from version 12.3.5.

The scripts in gitlab-shell/hooks/* scan the current repository and directories of the entire site. However, the directories of the entire site will not be created with a clean installation, and you need to create them yourself.

 mkdir -p <XXX>/gitlab-shell/hooks/pre-receive.d # or update.d or post-receive.d chown git:git <XXX>/gitlab-shell/hooks/pre-receive.d # link or copy your script of course it needs to be executable by the Gitlab user ln -s /usr/bin/my-hook <XXX>/gitlab-shell/hooks/pre-receive.d/my-hook 
0
source share

All Articles