This is a tutorial on how to setup Subversion to email a team when there is a commit to the repository.
Subversion Hooks
Hooks are what Subversion executes upon certain events. Within your SVN directory you should see the following items
- README.txt
- conf
- dav
- db
- format
- hooks
- locks
Go into the hooks directory and you will see a bunch of files ending in .tmpl. These are template scripts that are prebaked for you. Within each hook file are calls to scripts you want to be executed. To get one to execute you need to remove the .tmpl extension and then make it executable.
mv post-commit.tmpl post-commit<br /> chmod +x post-commit
The Post Commit Hook & commit-email.pl
In post-commit there is a call to commit-email.pl
. (Be sure that this calls to the absolute path of the script)
I didn’t have commit-email.pl
on my server but acquired it from the Subversion Tools Repository here.Save that file to your hooks directory. Also, be sure to edit that file and rename all the @SVN_BINDIR@
instances to the directory of you subversion executable. To find out type which svn
and use the path that returns. Mine returned /usr/bin/svn
to I used /usr/bin/
for @SVN_BINDIR@.
Run commit-email.pl without any arguments to see a list of options. To test this script point it to a repository and a revision number.
./commit-email.pl /var/svn/repository 1 --from "Subversion Gate Keeper <[email protected]>" [email protected] [email protected]
I like to prepend a subject line prefix so I can filter it a little easier when it comes through to my email client. Adding the -s
argument to the command will allow you to specify a subject line prefix.
./commit-email.pl /var/svn/repository 1 --from "Subversion Gate Keeper <[email protected]>" -s "Commit Activity: " [email protected] [email protected]
Here are some more resources to help you out.
Edit – October, 27: You have to call your scripts within post-commit by their absolute path or else they wont run. Code above has been modified.