Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #476

Closed
Open
Created Feb 27, 2012 by Administrator@rootOwner

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.

Assignee
Assign to
Time tracking