Mail notification for subversion repository
I was searching for a little script able to email my collaborators and myself when someone commits something to my SVN repositories.
There seem to be a popular perl script commit-email.pl. But I had several errors when implementing it. This is why I decided to make one. Because it's useful and easy to configure, I'll share my entire script here.
As you can see, there is a little configuration section.
- // CONFIGURATION
- $svnlook = '/usr/bin/svnlook';
- $globaladdress = 'email@example.com';
- $repoaddress = array(
- 'repoAAA' => 'firstname.lastname@example.org, email@example.com',
- 'repoBBB' => 'firstname.lastname@example.org, email@example.com',
- $from = 'firstname.lastname@example.org';
- $replyto = 'email@example.com';
Nothing fancy here. $svnlook is the path where the svnlook command can be run. $globaladdress is a email address where all commit will be notified. $repoaddress is a field for specific repositories to add email addresses. $from and $replyto are what they are.
It's following the svn postcommit hook. My SVN repos are located in /home/svn. You can create a hook in /home/svn/repoX/hooks/post-commit containing:
- /usr/bin/php /home/svn/commit-email.php "$REPOS"
Don't forget to place my script in /home/svn and to install php5-cli.