Implementing Subversion post-commit hook

Today I've configured Subversion to send a notification to a mail list every time one of developers commits a change to the specific project. This is obviously the most useful for a shared project and I do plan to expand SVN notifications to other projects as well. This is one of the ways we can all keep up with what's going on with shared projects, and will hopefully reduce the amount of "stepping on toes" when working on similar project.

Instead of using supplied with SVN commit-email.pl with hundred lines of Perl without an effort to format the check-in comment, I used SVN-Notify package. I added package to SVN server Linux machine that sends out an email notification when anyone checks in something to Subversion. The Subversion notification email contains the following information:
Developer that made the change
What files were changed
Check in comments
Diff of all of the changes that were made

The Perl SVN-Notify package has been installed in the /data/scripts/svnnotify directory and an SVN post-commit hook has been added to the /data/svn/company/hooks directory. The post-commit hook is a shell file that calls the SVN-Notify package with the information from the Subversion checking. This file controls what notification gets sent to whom. The post-commit file has the line :

--to-regex-map DevAlias@foo.bar.com=project \ 

This line controls who gets notified of what. The DevAlias@foo.bar.com can be any email or email list and can be multiple email addresses separated by a comma. After the = sign, is the SVN repository pattern that is matched to determine if an email is sent for this checkin. In the example above, only checkins on the "project" directory will generate an email to DevAlias@foo.bar.com. This line can be repeated for each pattern that needs to be matched. So, an email notification can be sent to just the email list for that application by having a line for each application.

Next step would be implementation of Subversion and Atlassian's Jira bug tracking tool integration. Developers would have ability to reference Jira issues when they make SVN commits.

Best SVN books

3 comments:

mcannon said...

Mate,

Good post! With regard to JIRA, just making sure you've seen the JIRA + Subversion plugin - which is free and has a whole host of connections between JIRA and Subversion.

Beyond that, you might also be interested in the Fisheye for JIRA plugin which can also do a similar connection (albeit a little smarter as it has the power of Fisheye on the backend).

Lastly, there's also the Commit Acceptance plugin which allows you to specify in JIRA conditions under which your SVN commits will be accepted or rejected (ie "All commits must contain an issue key"). Can be useful in strict development environments!

Hope these help. Good luck with it all.

m

MV said...

Thanks for pointing to 'Commit Acceptance plugin'. I've never heard about this plugin before and it is exactly for I wanted to have.

MokkaNanban said...

Thanks for the good post, can you please share the script, so that it will be useful for newbie like me.