How to get Subversion (SVN) to send emails for verification?

I always thought checkin (commit) messages are very useful for tracking other people's work in the database / repository. How to configure SVN to send a mailing list for each commit?

I run clients on Windows and the Apache Subversion server on Linux. The answers below for different platforms are likely to be useful to other people.

+50
svn post-commit-hook hook
Aug 11 '08 at 16:27
source share
16 answers

You are using post-commit hooks . Here is a guide .

Here is an example Ruby script that sends an email after each commit: commit-email.rb

+31
Aug 11 '08 at 16:35
source share

Check out the standalone Subversion Notify tool (Windows only!) It can send commits emails, and much more!

+19
Aug 11 '08 at 16:48
source share

You will want to familiarize yourself with the repository hooks , especially the post-commit hook .

+3
Aug 11 '08 at 16:34
source share

1) Install svnnotify on svn server using sudo apt-get

2) Use post-commit of your repo (read on hooks after commit on svn website)

3) Open the commit file after commit and paste the following code to send email using the SMTP server. Using smtp is straightforward since you do not need to configure sendmail.

4) Make sure that after \ (line break) you have no extra space.

#!/bin/sh REPOS="$1" REV="$2" TO="xyz@yah.com" # who will receive the notifications FROM="hello@goog.com" # what will be in "FROM" fields /usr/bin/svnnotify \ --repos-path "$REPOS" \ --revision "$REV" \ --to $TO \ --from $FROM \ --reply-to $FROM \ --smtp "YOUR.SMTP.MAIL.COM" \ --subject-prefix "[svn commit]" \ --attach-diff -a \ --header 'Message generated on Subversion Check-in.' \ --footer 'OpenSource Team. ' \ --svnlook "/usr/local/bin/svnlook" \ --handler HTML::ColorDiff # make diff pretty 
+2
Dec 13 '13 at 22:04
source share

Which platform?

On Mac OS X, I installed msmtp and created a post-commit script under the hooks in the repository. The .msmtprc file must be configured 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 recipients} <<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 recipients} specific to your needs. Note. I used UTF-8 because there are special characters in Sweden (Γ₯Àâ) here.

+1
Aug 11 '08 at 16:38
source share

There is a related question here on the hooks after fixing. Personally, I prefer to send a message to something that I can get from the RSS feed, as my mailbox will be loaded very quickly for each transaction via email.

+1
Aug 11 '08 at 17:32
source share

Seconding @ Matt Miller RSS Feeds.

There is a useful WebSVN tool that offers RSS feeds for each repository and individual branches / tags / folders with full commit messages. It is also a great web interface for quickly searching file history and commits / differences without having to start the update and open your editor.

+1
Aug 11 '08 at 22:22
source share

As someone else said, "which platform." On Windows, I used "blat", which is a free command-line SMTP email program, as well as post-commit and another batch file.

A 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 <me@my.email.com> -sf %temp%\subject.txt -server ServerName -f "SVN Admin <svn@my.email.com>" -noh2 

The biggest problem with writing SVN interceptors is that you may have no environment settings at all - no exe path, no temporary path, etc. Although possible, this has improved in later versions of SVN.

+1
Aug 11 '08 at 22:31
source share

I am using a post-commit script similar to this one .

It sends a good HTML letter. I updated it, where it highlights the code that was deleted in red, and highlights the code that was added in blue.

+1
Aug 25 '08 at 20:46
source share

You can use buildbot . This is a tool that can take arbitrary actions whenever a registration occurs. This is a full-featured continuous integration system, but if you just want to receive emails, it certainly can do it. It has plugins for various SCMs, including SVNs.

+1
Sep 17 '08 at 4:59
source share

There are 9 template files in the hooks directory of your specific subversion branch that you can run.

Key point: subversion will not execute any files until they are renamed. To execute post-commit.tmpl to run on unix, rename it "post-commit". On 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 who performs the disruptive operation.

+1
Aug 17 '10 at 20:26
source share

VisualSVN Server has a useful VisualSVNServerHooks.exe email notification clip. It supports color differences and can send commit notifications only when commit affects a specific repository path.

See "Configuring Email Notifications on the VisualSVN Server" .

+1
09 Oct '13 at 11:19
source share

I did this on a Linux server in 3 steps:

  • Create a mailing list ( svn-notify@xy.com ) and add people to the list.

  • Edit /path_to_your_svn/svn/hooks/svn-notify/mailer.conf

    • to_addr = svn-notify@xy.com
    • from_addr =% (author) s@xy.com
    • commit_subject_prefix = [XY-SVN]
  • Add this line to your /path_to_your_svn/svn/hooks/post-commit file:
    /path_to_your_svn/svn/hooks/svn-notify/mailer.py commit "$REPOS" "$REV" /path_to_your_svn/svn/hooks/svn-notify/mailer.conf
+1
May 30 '14 at 10:04
source share

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

0
Aug 11 '08 at 16:39
source share

Also SVNMailer , which runs on Linux.

0
Jan 27 '13 at 3:26
source share

Check out the svn-mod-email package described here . svn-mod-email is a powerful SVN email notification management tool that comes as a Debian archive. It is easy to install, configure and use.

0
Jun 19 '13 at 6:01
source share



All Articles