SVN安装这里就不赘述了,需要了解可参考以前的文章(如下链接)
https://mp.weixin.qq.com/s?__biz=MzI0MDQ4MTM5NQ==&mid=2247484395&idx=1&sn=fa514768d628649a104b32ba140087e4&chksm=e91b66f7de6cefe1cee310357feb9e26f694de3809bb5b89917ebb17421e96598eb4dcda7fac#rd
安装完成,开始配置hooks功能
[root@centos ~]#cd /svndata/doc/hooks
[root@centos hooks]#ll
total 40
-rw-r--r-- 1 root root 1977 Jun 8 23:50 post-commit.tmpl
-rw-r--r-- 1 root root 1638 Jun 8 23:50 post-lock.tmpl
-rw-r--r-- 1 root root 2289 Jun 8 23:50 post-revprop-change.tmpl
-rw-r--r-- 1 root root 1567 Jun 8 23:50 post-unlock.tmpl
-rw-r--r-- 1 root root 3426 Jun 8 23:50 pre-commit.tmpl
-rw-r--r-- 1 root root 2410 Jun 8 23:50 pre-lock.tmpl
-rw-r--r-- 1 root root 2786 Jun 8 23:50 pre-revprop-change.tmpl
-rw-r--r-- 1 root root 2100 Jun 8 23:50 pre-unlock.tmpl
-rw-r--r-- 1 root root 2780 Jun 8 23:50 start-commit.tmpl
备份下配置文件
[root@centos hooks]#cp post-commit.tmpl post-commit
[root@centos hooks]#chmod +x post-commit
修改post-commit配置文件
[root@centos hooks]# vim post-commit
#!/bin/sh
REPOS="$1"
REV="$2"
export LC_CTYPE="en_US.UTF-8"
export LC_ALL=
LOCALPATH="/svncode/test/"
WEBPATH=/usr/local/apache-tomcat-8.5.9/webapps/
DATE=`date +%F`
SVN=/usr/bin/svn
[ ! -d ${LOCALPATH} ] && mkdir ${LOCALPATH} -p
##update code
$SVN update ${LOCALPATH} --username=test --password=test123
#backup web dir
cd /usr/local/apache-tomcat-8.5.9/webapps/
mv test test.${DATE}
##update code and restart Tomcat service
ln -s $LOCALPATH $WEBPATH
cd /usr/local/apache-tomcat-8.5.9/bin/
./shutdown.sh
sleep 2
./startup.sh
备注:SVN服务器与WEB在同一台服务器上,如果分开,配置是需要有所变化的,以上配置供参考,但方法与步骤相同