0

I've got GitLab 8.16.4 and there are many groups with many projects. I'd like to create one location with many scripts run in loop as different hooks (just like in this solution Chaining git hooks) and in each project make custom_hooks folder as a symlink to that earlier mentioned location.

I've got test project: /var/opt/gitlab/git-data/repositories/test/test.git/. If I create there folder with hook (/var/opt/gitlab/git-data/repositories/test/test.git/custom_hooks/update) it's invoked. But if folder is symlink to other location hook isn't invoked.

I checked owners of folders/files, but they are ok.

Project:

lrwxrwxrwx 1 gitlab gitlab 31 Feb 6 13:37 custom_hooks -> /home/user/custom_hooks

/home/user/custom_hooks:

drwxr-xr-x 2 gitlab gitlab 4096 Feb 6 13:31 custom_hooks

lrwxrwxrwx 1 gitlab gitlab 10 Feb 6 13:26 /home/user/custom_hooks/update -> hook-chain

Is there anything wrong with my configuration or maybe GitLab doesn't allow to invoke hooks from other localisation than files within project?

Community
  • 1
  • 1
Maciej Szymonowicz
  • 603
  • 1
  • 6
  • 18

1 Answers1

0

Final solution:

  1. in /opt/gitlab/embedded/service/gitlab-shell/hooks/ create folders post-receive.d, pre-receive.d, update.d and myhooks
  2. in myhooks create hook-chain script and proper hooks to run by it
  3. in first three folders create symlinks to script hook-chain in myhooks, like:

    [root@server ~]# ll /opt/gitlab/embedded/service/gitlab-shell/hooks/update.d/
    total 4
    lrwxrwxrwx 1 gitlab gitlab 68 Apr 18 08:47 update -> /opt/gitlab/embedded/service/gitlab-shell/hooks/myhooks/hook-chain
    
  4. of course user gitlab has to be owner of all scripts

Maciej Szymonowicz
  • 603
  • 1
  • 6
  • 18
  • Does GitLab actually have to be the owner of the scripts - or just have the execute permission on the file? – Shadow Apr 26 '19 at 09:02
  • @Shadow Execute permission probably should be enough. I change owner. Which is done automatically by dedicated script. – Maciej Szymonowicz Apr 27 '19 at 12:27
  • Confirmed, execute is enough. I now have have gitLab-runner on the same server which updates these scripts as part of a CI job, so the user doesn't have permissions to change ownership. – Shadow Apr 27 '19 at 13:39