前端之家收集整理的这篇文章主要介绍了
Ubuntu下配置SVN自动发送邮件通知,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_
403_0@
Ubuntu下配置SVN
自动发送邮件通知
1.安装相关软件:sudo apt-get install libauthen-sasl-perl
如果没安装libauthen-sasl-perl,则会
提示错误:SMTP Error: Need MIME::Base64 and Authen::SASL todo auth
2.由http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/commit-email.pl.in下载脚本
文件,保存为commit-email.pl。
需要注意的是如果该文件是在windows下创建的,在拷贝到Ubuntu环境下需要转换格式,可使用dos2unix进行转换。
3.
修改commit-email.pl脚本:
1.commit-email.pl 的默认perl路径#!/usr/bin/env perl 改为/usr/bin/perl
2.设置smtp server,对于
公共邮件服务器还需要设置用户名密码:
my ($sendmail,$smtp_server);改为my ($sendmail,$smtp_server,
$uname,$passwd);
$smtp_server = "
smtp.163.com";
$username='mailaccount***';
$passwd='*******';
my $smtp = Net::SMTP->new($smtp_server)
or die "$0: error
opening SMTP session to `$smtp_server': $!/n";
之后加入
handle_smtp_error($smtp,$smtp->auth("$username","$passwd"));
./commit-email.pl /home/Share/hui/myandroid_R9/trunk/ 1
liuyh@tom.com--from
liuyh8@163.com
4.设置
邮件标题及
内容格式
4.将commit-emai.pl
文件保存到版本库父目录svnroot下:/usr/share/subversion/hook-scripts,在版本库的hooks目录(
可用命令locate post-commit查看svn hooks安装在什么目录,svn安装目录的hoots/post-commit才会被调用)/home/root/hooks中创建post-commit,
内容如下:
REPOS="$1"
REV="$2"
export LANG=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
export PATH=$PATH:/usr/share/subversion/hook-scripts
/usr/share/subversion/hook-scripts/commit-email.pl /
"$REPOS" "$REV" /
liuyh@tom.com/
--from
liuyh@163.com
5.设置commit-email.pl和post-commit的owner及权限: chown -R svn:svngroup /mnt/svnroot/commit-email.pl /mnt/svnroot/test/hooks/post-commit chmod 700 /mnt/svnroot/commit-email.pl /mnt/svnroot/test/hooks/post-commit 6.设置完成,可以
修改post-commit中"$REPOS"和"$REV"的值后使用bash post-commit进行测试。