Tag Archives: hook

Setup Gitolite v3 and Email Notifications

The most common setting would be to configure the email hooks to send notifications on a push operation. This is not hard, however, I found the information of how to setup email notifications are pieces and pieces everywhere online, some of them are targeting Gitolite v2, and some of them are misleading. After tried some approaches, and here is what works for me.

1. Setup hook scripts

I tried

[codesyntax lang="bash"]

ln -s /usr/share/doc/git/contrib/hooks/post-receive-email /home/git/.gitolite/hooks/common/post-receive

[/codesyntax]

However, my git user doesn’t have the permission to execute this script. So, finally, I decided to simply copy the script to user folder. Don’t forget to setup Gitolite (again) after put hook scripts into place, so that Gitolite can deploy scripts to all bare repositories.

[codesyntax lang="bash"]

cp /usr/share/doc/git/contrib/hooks/post-receive-email /home/git/.gitolite/hooks/common/post-receive
chmod a+x /home/git/.gitolite/hooks/common/post-receive
$HOME/bin/gitolite setup --hooks-only

[/codesyntax]

2. Setup .gitolite.rc

Edit ~/.gitolite.rc file, and change GIT_CONFIG_KEYS as '.*',

[codesyntax lang="bash"]

vim /home/git/.gitolite.rc
:%s/'',/'.*',/
:wq

[/codesyntax]

If you skip this step, following errors will be presented when attempt to push repository specific configurations.

remote: FATAL: git config 'hooks.mailinglist' not allowed
remote: check GIT_CONFIG_KEYS in the rc file

If you installed git using my previous article about how to migrate from svn to git then you already have changed this.

3. Setup repositories

For the repositories desire to send email notifications, add

config hooks.mailinglist = 'user1@example.com, user2@example.com'
config hooks.emailprefix = '[repo_name] '

to local gitolite-admin repository as discribed in the Giolite README, then push.