安装环境: CentOS 5.1 + subversion-1.4.4 + httpd-2.2.8
Subversion + httpd的安装就不多说了,google一堆.我这里完全yum 安装
这里主要说一下邮件报告的问题:
svn主目录为: /var/www/svn/stuff
相关脚本:/usr/share/doc/subversion-1.4.4/tools/hook-scripts
/var/www/svn/stuff/hooks/
post-commit: 在 transaction 完成而 commit 結束,建立了新的 revision 之后执行,常用来发送邮件,我们就选他了:)
1.打开post-commit
# cd /var/www/svn/stuff/hooks/
# cp post-commit.tmpl post-commit
# chmod a+x post-commit
2.准备邮件脚本
# cp /usr/share/doc/subversion-1.4.4/tools/hook-scripts/mailer/mailer.conf.example /var/www/svn/stuff/conf/mailer.conf
# chown apache:apache mailer.conf
# cp /usr/share/doc/subversion-1.4.4/tools/hook-scripts/mailer/mailer.py /var/www/svn/stuff/hooks/
# chmod a+x mailer.py
对于mailer.py的参数说明,执行一下该脚本就有详细的说明:
[root@smtp mailer]# python mailer.py
USAGE: mailer.py commit REPOS REVISION [CONFIG-FILE]
mailer.py propchange REPOS REVISION AUTHOR REVPROPNAME [CONFIG-FILE]
mailer.py propchange2 REPOS REVISION AUTHOR REVPROPNAME ACTION [CONFIG-FILE]
mailer.py lock REPOS AUTHOR [CONFIG-FILE]
mailer.py unlock REPOS AUTHOR [CONFIG-FILE]
If no CONFIG-FILE is provided, the script will first search for a mailer.conf
file in REPOS/conf/. Failing that, it will search the directory in which
the script itself resides.
ACTION was added as a fifth argument to the post-revprop-change hook
in Subversion 1.2.0. Its value is one of 'A', 'M' or 'D' to indicate
if the property was added, modified or deleted, respectively.
3.案例
3.1 /var/www/svn/stuff/conf/mailer.conf
[general]
diff = /usr/bin/diff -u -L %(label_from)s -L %(label_to)s %(from)s %(to)s
mail_command = /usr/sbin/sendmail
smtp_hostname = mail.atyu30.com
smtp_username = atyu30
smtp_password = atyu30password
[defaults]
commit_subject_prefix = [repocommit]
propchange_subject_prefix = [repopropchange]
from_addr =
to_addr = devel@atyu30.com
reply_to =
generate_diffs = add copy modify
suppress_deletes = yes
这里采用公网上的邮件服务器帐号发送邮件,其中devel@atyu30.com可以是一个邮件组(发给多个用户),如果不指定 from_addr ,From: 会自动填入 committer 的使用者名称。
3.2 /var/www/svn/stuff/hooks/post-commit
#!/bin/sh
REPOS="$1"
REV="$2"
/var/www/svn/stuff/hooks/mailer.py commit "$REPOS" "$REV"
#log-commit.py --repository "$REPOS" --revision "$REV"
3.3 /var/www/svn/stuff/hooks/mailer.py
这个文件是直接拷贝过来的不用修改
这里需要注意脚本的可执行权限,及其属主,没有特别说明的文件就不用管了,我这里测试是发送成功了,祝你好运!有问题密我:)
至于相关说明我就不误导你们了,请多看手册
参考:svnbook 第 5 章的 Hook Scripts
阅读(2223) | 评论(0) | 转发(0) |