Gitolite v3 – add email hook

I added the email hook by changing files on the git server.

gitolite@gitserver~$ cd .gitolite/hooks/common
gitolite@gitserver:~/.gitolite/hooks/common$ cp /usr/share/doc/git/contrib/hooks/post-receive-email post-receive
gitolite@gitserver:~/.gitolite/hooks/common$ $HOME/bin/gitolite setup --hooks-only
gitolite@gitserver:~/.gitolite/hooks/common$ cd
gitolite@gitserver:~$ vi .gitolite.rc
#GIT_CONFIG_KEYS => '', # ORIGINAL
GIT_CONFIG_KEYS => '.*', # EDIT TO THIS

For the git server that’s all for the changes needed.

Now, where you have the gitolite-admin directory:

In the conf/gitolite.conf

In the repository you want to have the email add the following

config hooks.mailinglist = "person@example.com"
config hooks.emailprefix = '[repo_name] '

Example:

repo test1
RW+     =   mfang @admin
R       =   @staff
config hooks.mailinglist = "person@example.com"
config hooks.emailprefix = "[test1]"

It sends out email using SSMTP:

To setup edit /etc/ssmtp/ssmtp.conf

root=noreply@gmail.com
mailhub=smtp.gmail.com:465
AuthUser=noreply@gmail.com
AuthPass=PASSWORD
RewriteDomain=gmail.com
FromLineOverride=YES
UseTLS=YES

To Test:
In test1, edit something.

git commit # git commit -a -m 'message'
git push # git push origin master

It took me a little while to remember that I needed to push to have the email sent.

According to a stackoverflow article you can add the email hook from the client gitolite-admin directory also. Haven’t tried it.
Links:
LongYi Qi – very helpful for Gitolite v3. Instruction to setup ssmtp too
HaveTheKnowHow – used this to configure my ssmtp

Advertisements
This entry was posted in Git and tagged , , , . Bookmark the permalink.

One Response to Gitolite v3 – add email hook

  1. Be sure to make post-receive executable. i.e. chmod ugo+x post-receive

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s