标签:svn
方法对比:update和export对比钩子模版: 仓库中hooks目录下post-commint模版可以触发
shell>cp post-commit.tmpl post-commit
shell>chmod +x post-commit
shell>vim post-commit
REPOS="$1" //仓库名
REV="$2" //版本
LOGPATH="/app/log" //存放日志
export LANG=zh_CN.UTF-8
[ ! -d ${LOGPATH} ] && mkdir ${LOGPATH} -p
SVN=/usr/bin/svn
echo "code Deployed by at $REPOS,$REV" >> /app/log/log.log
cd /backup
/usr/bin/svn update --username admin --password 123com /backup //将代码先更新到/backup目录,之前需要通过svn co 导出一份到/backup目录,才能update
if [ $? -eq 0 ]
then
rsync -avz /backup/ rsync_user@x.x.x.x.::backup/ --password-file=/etc/rsync.password
fi
如果不
cd /backup 目录下进行update会报错
[root@node104 test]# svn update svn://x.x.x.x:20000/test /backup/
Skipped ‘svn://x.x.x.x:20000/test‘
Skipped ‘/backup‘
shell>vim post-commit
REPOS="$1" //仓库名
REV="$2" //版本
LOGPATH="/app/log" //存放日志
export LANG=zh_CN.UTF-8
[ ! -d ${LOGPATH} ] && mkdir ${LOGPATH} -p
SVN=/usr/bin/svn
echo "code Deployed by at $REPOS,$REV" >> /app/log/log.log
cd /backup
/usr/bin/svn export svn://x.x.x.x:20000/test /backup --force --username abc --password 12345 --no-auth-cache //直接将文件导入/backup,再用sync同步到生成服务器
if [ $? -eq 0 ]
then
rsync -avz /backup/ rsync_user@x.x.x.x.::backup/ --password-file=/etc/rsync.password
fi
注:
--force 是说强制覆盖/backup这个文件夹,避免这个文件夹不为空时报错
--no-auth-cache 是说不缓存用户名和密码,这是出于安全考虑
SVN使用钩子函数(post-commit)自动推送到业务服务器
标签:svn
原文地址:http://blog.51cto.com/7603402/2092039