SVN利用POST-COMMIT钩子自动部署代码到生产环境中
时间:2015-09-20 23:14来源:linux.it.net.cn 作者:IT
首先创建svn版本库/data/svn/jincon.com,然后在svn库中创建svn钩子,在开发电脑上检出最初版本,并且将自己的代码 提交到svn上,此时svn钩子将会把代码实时检出/更新到/data/site/www.jincon.com站点目录中。最后访问浏览器测试。
1、先创建版本库:
svnadmin create /data/svn/jincon.com
2、编辑post-commit文件
1 |
# vim /data/svn/jincon.com/hooks/post-commit |
3、post-commit代码:
04 |
# description:用于实时检出的钩子 |
07 |
export LANG=en_US.UTF-8 |
09 |
dateTimeMinute=`date +%H%M%S` |
10 |
binSvn=/usr/bin/svn #你svn的绝对路径 |
11 |
dirHtmlApp=/data/site/www.jincon.com #检出的web站点根目录 |
12 |
logFileName=/tmp/svnhooks_${dateTime}.log |
18 |
# 检出或者更新subversion,钩子的核心功能 |
19 |
echo "-- $dateTimeMinute" >> $logFileName |
20 |
if [ ! -d $dirHtmlApp/.svn ]; then |
22 |
echo "$binSvn co file://$REPOS/ $dirHtmlApp" >> $logFileName |
23 |
$binSvn co file://$REPOS/ $dirHtmlApp |
25 |
echo "checkout ok" >> $logFileName |
27 |
echo "checkout error" >> $logFileName |
31 |
echo " $binSvn up $REV $dirHtmlApp " >> $logFileName |
32 |
$binSvn up $REV $dirHtmlApp >> $logFileName |
34 |
echo " update sucess " >> $logFileName |
36 |
echo " update fial " >> $logFileName |
39 |
echo "--" >> $logFileName |
(责任编辑:IT) |
------分隔线----------------------------