tags:

views:

4897

answers:

12

I've always found checkin mails to be very useful for keeping track of what work other people are doing in the codebase. How do I set up SVN to email a distribution list on each checkin?

Edit: I'm running clients on Windows and the server on Linux. The answers below for various platforms will likely be useful to other people though.

+3  A: 

You'll want to familiarize yourself with repository hooks, particularly the post-commit hook

Rytmis
+10  A: 

You use the post-commit hooks. Here's a guide: http://builddeploy.blogspot.com/2008/01/implementing-subversion-post-commit.html

Here's a sample script that sends an email after each commit: commit-email.rb

pix0r
+1  A: 

What platform?

On Mac OS X I have installed msmtp and created a post-commit script under hooks in the repository. A .msmtprc file needs to be setup for the svn (or www) user.

REPOS="`echo $1 | sed 's/\/{root of repository}//g'` "
REV="$2"
MSG=`/usr/local/bin/svn log -v -r HEAD https://localhost$REPOS`

/usr/local/bin/msmtp {list of recipents} <<EOF
Subject: SVN-Commit $REPOS#$REV
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8Bit

$MSG
EOF

Make {root of repository} and {list of recipents} specific for your needs. Note I have used UTF8 because we have some special characters here in sweden (åäö)

epatel
A: 

There is a (large) example written in Perl included in the Subversion source (it can be viewed here).

Sean Carpenter
+6  A: 

Have a look at Subversion Notify (Windows only)

http://sourceforge.net/projects/svn-notify/

http://www.subversionnotify.com/

It can do emailing on commit and also much more!

Marius
+1  A: 

There's a related question here on post-commit hooks. Personally, I prefer to send a message to something I can get an RSS feed from, as an email-per-commit would overload my inbox pretty quickly.

Matt Miller
+1  A: 

Seconding @Matt Miller on RSS feeds.

There's a useful tool called WebSVN that offers RSS feeds of every repository and individual branches/tags/folders with full commit messages. It's also a great web interface for quickly looking at file histories and commits/diffs without having to run an update and open your editor of choice.

Jason Sparks
+1  A: 

As someone else said, 'what platform'. On Windows I've used 'blat', which is a freebie command line SMTP mailer to do this, along with a post-commit and another batch file.

The post commit looks like this: (Just calls another batch file)

 call d:\subversion\repos\rts\hooks\mail %1 %2

And mail.bat looked like this:

copy d:\subversion\repos\RTS\hooks\Commitmsg.txt %temp%\commit.txt
copy d:\subversion\repos\RTS\hooks\subjbase.txt %temp%\subject.txt
svnlook info -r %2 %1 >> %temp%\commit.txt
echo Revision %2 >> %temp%\commit.txt
svnlook changed -r %2 %1 >> %temp%\commit.txt
svnlook author -r %2 %1 >> %temp%\subject.txt
c:\utils\blat %temp%\commit.txt -t <[email protected]> -sf %temp%\subject.txt -server ServerName -f "SVN Admin <[email protected]>" -noh2

The biggest gotcha in writing SVN hooks is that you might have basically NO environment set-up - no exe path, no temp path, etc. Though maybe that's improved in more recent SVN builds.

Will Dean
+1  A: 

I use a post-commit script similar to this one

It's sends a nice HTML email. I updated it some where it highlights code that was removed in red and highlights code that was added in blue.

Mark Spangler
+1  A: 

You could use buildbot. It's a tool that can take arbitrary action whenever a check-in occurs. It's a full featured continuous integration system but if you just want emails it can certainly handle that. It has plug-ins for a variety of SCMs including SVN.

whitney
A: 

I have understand a Bit from you Guys. Thanks

I am using WINDOWS 2003 AS Subversion Server. Now i want to send Emails whenever a File get Updated in Developer's workspace in Trunk.

i HAVE understand that this is possible due to "Post-Commit Hook" and you may write down a Batch file.

Please set an Example for this

Awaiting your response

Regards WSBokhari

Waseem Bokhari
If you wish to ask another question, please do it as a question, not an answer
Casebash
A: 

In the "hooks" directory of your specific subversion branch there are 9 template files to get you started.

Key point: subversion will not execute any of the files until they are renamed. To get post-commit.tmpl to execute under unix, rename it "post-commit". Under Windows, rename it to "post-commit.bat" or "post-commit.exe". Subversion will not execute the file if it is named "post-commit.tmpl" or "post-commit.sh" or the like.

Also, make sure that the file is executable by the same user that runs subversion.

Logan