Search code examples
gitgitlabgitlab-cihook

Gitlab Server Hook version 16.1


Related with this issue The server-hook dont work

Im trying to create a server-hook in gitlab. The objective is to create a hook that fires when any user push. We tried several things:

  1. Uncomment the custom hooks dir line

Follow the official docs : guide

Go to the gitlab.rb(configuration file), then uncomment the line:

gitaly['configuration'][:hooks][:custom_hooks_dir]='var/opt/gitlab/gitaly/custom_hooks'

This is the folder where server-hooks are supposed to be placed.

Following the guide : Create the folder pre-receive.d :absolute( var/opt/gitlab/gitaly/custom_hooks/pre-receive.d)

https://docs.gitlab.com/ee/administration/server_hooks.html#create-the-global-server-hook

Then add the script with the shebang, for example:

var/opt/gitlab/gitaly/custom_hooks/demohook

#!/bin/sh
echo "GL-HOOK-ERR: My custom error message.";
exit 1

Then gitlab reconfigure, fails saids its deprecated(eventhough is in the official guide).

2.Adding gitaly configuration to the file Found that first way of configuration could be obsolete, tried adding to gitlab.rb:

gitaly['configuration'] = {
  hooks: {
    # gitaly['custom_hooks_dir']
    custom_hooks_dir: '/var/opt/gitlab/gitaly/custom_hooks'
  }

}

Nothing works. Any help is welcome.


Solution

  • Finally the problems were related to the permissions of the hook.

    As the directory does not have sufficient capacities, the error does not even appear in the log.

    Aplying the next commands:

    chmod +x hook
    chown userWithPrivileges:userWithPrivileges hook