How do I make Subversion (SVN) send email on checkins?

76,844

Solution 1

You use the post-commit hooks. Here's a guide.

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

Solution 2

Have a look at the standalone Subversion Notify tool (Windows only!) It can do emailing on commit and also much more!

Solution 3

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

Solution 4

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

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

3) Open post-commit hook file and paste following code to send an email using smtp server. Using smtp is straight forward since you don't need to configure sendmail.

4) Make sure after \ (line break) you don't have an extra space.

#!/bin/sh

REPOS="$1"
REV="$2"
TO="[email protected]" # who will receive the notifications
FROM="[email protected]" # 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

Solution 5

VisualSVN Server has useful commit e-mail notification hook VisualSVNServerHooks.exe. It supports colored diffs and can send commit notifications only when commit affects certain repository path.

See "Configuring Email Notifications in VisualSVN Server".

Share:
76,844
Joe Ludwig
Author by

Joe Ludwig

I have been in the game industry since 1998, and at Valve since June 2009. If you'd like to know more, feel free to visit my blog.

Updated on September 18, 2020

Comments

  • Joe Ludwig
    Joe Ludwig almost 4 years

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

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

  • NLV
    NLV over 13 years
    SubVersionNotify is really a brilliant little tool. Worked perfectly for me. Thanks.
  • user1633823
    user1633823 over 10 years
    Hi mark can you please advise how to add this script as I need exactly the same script through which I can get detailed mail now I am using SVN and I can access my repository through tortoise SVN browser please advise how to implement this script so that I can also start receiving the mails
  • Mark Spangler
    Mark Spangler over 10 years
    @user1633823 you just need to follow the install instructions on the site. But basically you just copy the script to the hooks/post-commit directory where your svn server is running & make it executable.
  • Peter Mortensen
    Peter Mortensen almost 8 years
    The link is (effectively) broken (it redirects to a generic page).