Wednesday, May 4, 2011

Setting up email notification of Subversion(SVN) commits

To set up email notification of Subversion commits, create a file called post-commit in your /home/username/svn/repos/hooks/ directory via a shell account
(replace username with your user name and repos with the name of your Subversion repository).

To do this with nano, you could just enter:
nano /home/username/svn/repos/hooks/post-commit

Once you’ve created the file, add the following and save it:
#!/bin/sh
REPOS="$1"
REV="$2"
/usr/local/bin/svnnotify -r $REV -C -d -H HTML::ColorDiff -p $REPOS -t to-mail@domain.tld 
--from from-mail@domain.tld --reply-to reply-to@domain.tld

and replace the to-mail@domain.tld, from-mail@domain.tld, and reply-to@domain.tld with the appropriate addresses.

Note: The post-commit script needs to be executable by the www user.
You can test the script out without having to commit. SSH in, cd to the hooks directory and run:

./post-commit path/to/your/repos #
(where # is a valid SVN revision in your repository)

--Cheers,
Varra

No comments:

Post a Comment