2

I have VisualSVN Server running on my server and I have created a post-commit hook to send an email to me when someone commits code, using the steps outlined here: http://www.visualsvn.com/support/topic/00018/

However, I would like to be able to have an email sent to one person if a certain project in SVN has been committed to, but someone else should receive an email if another project is committed to.

How can I go about creating multiple post-commit hooks to send emails to different people depending on on which project is committed to?

bahrep
  • 29,961
  • 12
  • 103
  • 150
dleerob
  • 4,951
  • 4
  • 24
  • 36

2 Answers2

1

You might want to look at my post-commit Watch script. This will eliminate your need for multiple post-commit hooks in this circumstance.

This script will send email to multiple users depending what gets changed. The main purpose of this script is to allow users to set their own watches. Users can specify files or directories using glob or regex patterns. You can use my pre-commit script to prevent users from changing other user's watch files. This way, no one has to bother you when they need these types of notifications which can cut into your Candy Crush time.

Users can also set up which email accounts they'd like the watches to go to. Users can setup these notices to go to multiple email accounts, or even to email accounts associated with SMS, IM, Twitter, or Facebook accounts if they prefer notifications that way.

The hook uses Perl, but the standard Perl installation will work without having to add any additional modules. It should work with all Perl from 5.8.8 onwards too. Windows users can download install the most recent version of Perl for free since it's open source.

David W.
  • 105,218
  • 39
  • 216
  • 337
0

I figured it out. I simply entered the next hook underneath my initial one, separating them with line. Eg:

    "%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" ^
    commit-notification "%1" -r %2 ^
    --from svn@mycompany.co.za --to me@mycompany.co.za ^
    --smtp-server mail.mycompany.co.za ^
    --detailed-subject

   "%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" ^
    commit-notification "%1" -r %2 ^
    --from svn@mycompany.co.za --to someone_else@mycompany.co.za ^
    --smtp-server mail.mycompany.co.za ^
    --detailed-subject
dleerob
  • 4,951
  • 4
  • 24
  • 36
  • Subject appears as R127 updated by USER. R127 is revision number not the project name. How to put project name on the subject? – Mehmet Fide Jul 10 '14 at 00:22
  • I'm not sure. I currently look in the body of the email notification at the "Changed paths" to see which projects were changed. Perhaps you cannot put it in the subject, as what if that commit affected a number of paths/projects. Which on would it put in the subject? If you find a way, please let me know. – dleerob Jul 10 '14 at 14:51
  • 1
    If you're following the [link you posted](http://www.visualsvn.com/support/topic/00018/), it says `To enable it email notifications on every commit...` i.e. global commit level. You can also do this in a per-project level by right clicking on the project > properties > hooks > post-commit hook (edit). Not quite as powerful if you want all projects and emails listed in the one script, but powerful enough if you want to customise the subject etc. for each one. – thinkOfaNumber Oct 29 '14 at 05:05