SVN email notification is important when many programmer involves in software development. For example, you are working on module and other programmers are using that. So if you check-in updated the classes , you have to notify other developers that module has been updated.
SVN provide post commit hook option, there you can add any script or programme that would be execute after SVN commit. Here I will add email notification in post-commit hook script.
I have create a repository in /apps/subversion/hsolite/.
Using ls command you can see default directories created under repository. There is a directory called hooks where you will put you post-commit script. When any user will commit in SVN, post-commit script will be execute.
To send email notification you need find out "mailer.py" and "mailer.conf"
[root@domU-12-31-39-09-29-13 hsolite]# find / -name "mailer.py"
/usr/share/doc/subversion-1.6.11/tools/hook-scripts/mailer/mailer.py
SVN provide post commit hook option, there you can add any script or programme that would be execute after SVN commit. Here I will add email notification in post-commit hook script.
I have create a repository in /apps/subversion/hsolite/.
Using ls command you can see default directories created under repository. There is a directory called hooks where you will put you post-commit script. When any user will commit in SVN, post-commit script will be execute.
To send email notification you need find out "mailer.py" and "mailer.conf"
[root@domU-12-31-39-09-29-13 hsolite]# find / -name "mailer.py"
/usr/share/doc/subversion-1.6.11/tools/hook-scripts/mailer/mailer.py
[root@domU-12-31-39-09-29-13 hsolite]# find / -name "mailer.conf"
/usr/share/doc/subversion-1.6.11/tools/hook-scripts/mailer/tests/mailer.conf
Now copy the mailer.py and mailer.conf under /apps/subversion/hsolite/hooks and /apps/subversion/hsolite/ respectively.
[root@domU-12-31-39-09-29-13 hsolite]# cp /usr/share/doc/subversion-1.6.11/tools/hook-scripts/mailer/mailer.py /apps/subversion/hsolite/hooks/mailer.py
[root@domU-12-31-39-09-29-13 hsolite]# cp /usr/share/doc/subversion-1.6.11/tools/hook-scripts/mailer/tests/mailer.conf /apps/subversion/hsolite//mailer.conf
Now edit the mailer.conf and override following properties
mail_command = /usr/sbin/sendmail
commit_subject_prefix = [svn-myproject]
from_addr = noreply@mydomain.com
to_addr = commits-myproject@mydomain.com # this is a mailing list
Under hooks directory you will find "post-commit.tmpl" that you need to rename to "post-commit".
Replace "post-commit" script contains with the following snippet.
------------------------------------------------
#!/bin/sh
REPOS="$1"
REV="$2"
/apps/subversion/hsolite/hooks/mailer.py commit "$REPOS" "$REV" /apps/subversion/hsolite/mailer.conf
-------------------------------------------------------
Make sure "post-commit" is executable.
[root@domU-12-31-39-09-29-13 hsolite]# chmod +x post-commit
Testing :
Using svnlook yon can get latest revision number.
[root@domU-12-31-39-09-29-13 ~]# svnlook info /apps/subversion/hsolite/
sujankn
2013-08-16 07:41:29 -0400 (Fri, 16 Aug 2013)
0
[root@domU-12-31-39-09-29-13 ~]# svnlook youngest /apps/subversion/hsolite/
2850
Test the hook script:
[root@domU-12-31-39-09-29-13 ~]# REPOS=/apps/subversion/hsolite/
[root@domU-12-31-39-09-29-13 ~]# REV=2850
[root@domU-12-31-39-09-29-13 ~]# "$REPOS"/hooks/mailer.py commit "$REPOS" $REV "$REPOS"/mailer.conf
After run above command you should receive email notification with revision number 2850
[root@domU-12-31-39-09-29-13 ~]# REPOS=/apps/subversion/hsolite/ [root@domU-12-31-39-09-29-13 ~]# REV=2850 [root@domU-12-31-39-09-29-13 ~]# sh $REPOS/hooks/post-commit $REPOS$REV
If post-commit script run successfully then commit some files in SVN then check your email inbox for notification.