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?
Subversion ( ) commit email
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.
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.
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.
Check the svn-mod-email package described here. The svn-mod-email is a powerful tool for SVN email notifications management that is delivered as a Debian archive. It's easily to install, configure and use.
To get an automatic email from a Subversion (SVN) server when a commit occurs on a repository you can use a post-commit hook on the SVN server. Hooks allow you (the server administrator) to execute a program or script when a particular event occurs in a repository on the SVN server (e.g. a commit, lock or revision properties change). So to get an email after a commit occurs, we need to call a program to create an email on the post-commit hook.
In the following examples my server has domain sandilands.info, is running Ubuntu Server 10.04 LTS and includes a Postfix email server. Change the directories, repositories and email addresses to suit your server.
Now the main part is to edit the hook (which is just a Shell script) to call a program to send an email. If you install subversion-tools there is a Perl script that will do it for you: /usr/share/subversion/hook-scripts/commit-email.pl.
The first two lines above set variables, REPOS and REV, for the repository name and current revision, respectively. I commented out the example line that called mailer.py by starting the line with a #. Then the last line I added. It calls commit-email.pl which takes several input arguments, some of which are optional. The first two are the repository name and revision. The third is the destination email address. The remaining are optional. The -s "SVN Steve:" adds the given string to to the start of the email subject. The --from sets to from address in the email. For other options, look inside the Perl code itself in commit-email.pl: start at line 145 you can see the different options.
Now, when ever there is a commit on the repository, an email will be sent to the selected destination address summarising the commit, including revision number, log message and diff between the head and most recent revision.
To subscribe to the lists above, simply send email to LISTNAME-subscribe@subversion.apache.org (where LISTNAME is the name of the list: "dev", "users", etc.) from the email address you wish to be subscribed.
To unsubscribe from the lists above, simply send email to LISTNAME-unsubscribe@subversion.apache.org (where LISTNAME is the name of the list: "dev", "users", etc.) from the email address you wish to be unsubscribed.
If that doesn't work, ensure that you are attempting to unsubscribe the correct email address. Look at the Return-Path header in one of the list mails to determine which email address is subscribed, and then send email to LISTNAME-unsubscribe-some.name=some.domain@subversion.apache.org.
We use svnmailer for this. We symlink our repository-specific post-commit hook scripts to a single script, which in turn calls svnmailer. The configuration is pretty straight forward, and with their simple.conf example configuration you can be up and running in a few minutes. Note that it is written in Python, so that is a prerequisite to installation.
I'm looking for something that allows a summary of repository files changed and the contents of the actual diffs to be sent to all members of a development team by email when commits occur, perhaps with links to the full affected source file at ViewVC or something. That's optional.
I definitely want the actual diff/code excerpts to be neatly compartmentalised. Nobody is going to look at these things (as if they will anyway :-) if it's just a big, reckless dump of incomprehensible code fragments right from the beginning. In principle, I just want to see the revision number, summary, user who made the commit, and a list of affected repository files.
Your mention of hooks is actually not far off the answer. You can use the post commit hook to run commit_email.pl (contents of), which is bundled with Subversion, that will give you pretty much what you're after. It'll need tweaking to point to your mail server but that's just a variable near the top of the script. You'll also need Perl installed to run the script.
The post commit hook differs in file name depending on the OS you're running on. You'll find it in the /hooks/ subfolder. For Linux its simply post-commit whilst on Windows its post-commit.bat. All you would need to do is modify that file to run commit_email.pl. Below is an example post-commit.bat:
Also, I made further change to our email script to show the email address of who the commit was from, instead of the Subversion user name. It makes the email sent a bit more useful (you can actually reply to it).
I have used svn-mailer before and love its ability to configure the email contents as well as subject. This time I am interested in the DIY approach to learn more about SVN, so I did it without svn-mailer.
The first step is to go to my svn repository (/var/svn in this case) and create a script call post-commit in the hooks directory. Subversion looks for this file, so the name must be exact. The script must be executable. Here it the contents of /var/svn/hook/post-commit:
The script employs two tools to accomplish its objective: svnlook to retrieve various information regarding the committed revision and mail, the Unix command-line utility to send out email. I assume that your system is set up to allow sending email.
To implement commit email notifications on SourceForge 4.x, you must install extra commit hook scripts in the repository. For detailed information see the online Subversion documentation: Hook Scripts.
The subversion version control system has a wonderfully handy feature called hooks. Hooks are essentially scripts that are triggered by a version control event (such as a commits, or revision property changes).
As with any server, you should also make sure your subversion server is patched for security vulnerabilities. A good way to keep updated on subversion vulnerabilities is with stack.watch. It will help you by sending you an email when new vulnerabilities are published.
Uses Subversion's mailer.py post-commit hook to mail diffs of all Nmap SVN repository commits as they happen (or you can subscribe to the daily digest). This list is only for automated messages -- all discussion should occur on nmap-dev.
You can use any script or program you like, in any language you like, as a commit hook. Simply place it in the hooks directory and name it start-commit, pre-commit, and post-commit as required. It must be executable, and if it is a script, make sure that the shebang (#! line is present and points to the correct location for whatever language you are using.
One obvious option for which a commit hook is useful, and one which most environments will have in place, is to send an email when a commit occurs. This will be a post-commit hook, using the variables that Subversion hands to the hook on commit.
Another useful post-commit hook is one that runs a backup of the repository after each commit. You can simply back up to another local disk, or run rsync to a non-local server, using passphraseless ssh. A suitable post-commit script using non-local rsync might look like this:
If a start-commit hook script exits non-zero (failure), the commit is stopped before a transaction is even created. So you could use a start-commit hook to check whether a user has appropriate permissions. For example, you might run a repository which anyone can check out and build, but to which commits are restricted.
Mike West works and plays on the internet. Currently working as a software engineer on Google's Chrome team in Munich, he tries to make the web platform marginally less insecure than it generally is. Drop him an email at mike@mikewest.org follow him on Twitter or circle him on Google+
I came up with two solutions. Neither is very clever, but they both give a little clue at least. The first looks through the log and determines who has committed changes to that file the greatest number of times. The second looks at the blame log for the file to determine who has modified the most lines in the file. My script just emails both people
Public SVN repo topics consist of 'svn', the first one or two path segments after the /repo/ in the URL, and 'commit'.For example, changes to the repository have the topics svn/dist/release/commit.A commit that involves changes to both dist/release and dist/dev has the topics svn/dist/commit.Note that svn/dist/release/commit will not match, because the topics in the response do not include release.
where $REVNO is some revision number (for example the one returned by svnlook youngest). After this you should receive an email with the details of the commit, or some error message should appear in the terminal that you can debug. 2ff7e9595c
Comments