Get svn commit notification right into your inbox by using svn hook post-commit

By bansalakhil July 11, 2007

If you wish you can get notification right into your inbox when a team member commits the code. This mail will contain list of files added/deleted along with the svn diff of files that are modified. This needs some extra efforts to setup, but once it is setup it is very helpful.

This can be done by using svn hooks. Yes, svn has inbuilt hook functionality like pre-commit, post-commit, post-lock, post-unlock, pre-lock, pre-unlock, start-commit. We’ll use post-commit hook to get notifications.

First of all get a perl script from here and copy it to hooks directory inside your repository directory, lets say /var/www/repos/repository_name/hooks.
Make sure to rename it as, ofcourse you need perl installed on your server. Now cd to hooks directory inside you repository directory. Rename post-commit.tmpl to post-commit, and chmod 755 to post-commit and . Now open post-commit in you favorite editor, and put “/usr/bin/perl /var/www/repos/ –from -s ‘SVN commit notification’ ‘$REPOS’ ‘$REV’,” at the bottom of that file. Now open and make changes in configuration section according to your requirement and server, specially svnlook path.

Congrats!, You are done 😉 .

Now your server will send email notification to, whenever someone commits.

**For security reasons, the Subversion repository executes hook scripts with an empty environment that is, no environment variables are set at all, not even $PATH or %PATH%. Because of this, a lot of administrators are baffled when their hook script runs fine by hand,but doesn’t work when run by Subversion. Be sure to explicitly set environment variables in your hook and/or use absolute paths to programs.

It worked for me, Please let me know if it works for you too.

Share this:

Leave a comment

Your email address will not be published. Required fields are marked *