Custom post-receive hook inclusion
Created by: netdata-be
Gitlab overwrites the already existent post-receive hook to update the gitlab projects.
However I currently use this hook for custom code as well. Therefore it would be better to use an include dir as documented for the "update.secondary.d" dir
So do the following steps:
- Create a directory ~/.gitolite/hooks/common/post-receive.secondary.d
- Overwrite the post-receive hook with the following content:
#!/bin/bash
[ -d hooks/post-receive.secondary.d ] || exit 0
# all output from these "hooklets" must go to STDERR to avoid confusing the client
exec >&2
for i in hooks/post-receive.secondary.d/*
do
[ -x "$i" ] || continue
# call the hooklet with the same arguments we got
"$i" "$@" || {
# hooklet failed; we need to log it...
echo hooklet $i failed
perl -I$GL_BINDIR -Mgitolite -e "log_it('hooklet $i failed')"
# ...and send back some non-zero exit code ;-)
exit 1
}
done
exit 0
- Place the actual required code for updating gitlab into the directory ~/.gitolite/hooks/common/update.secondary.d
This makes it possible to just include custom hooks.