svn钩子

#!/bin/bash
# description:用于实时检出的钩子
  
# 基本变量
export LANG=en_US.UTF-8
dateTime=`date +%F`
dateTimeMinute=`date +%H%M%S`
binSvn=/usr/local/subversion-1.8.5/bin/svn # 你svn的绝对路径
dirHtmlApp=/data/site/test.ttlsa.com #检出的web站点根目录
logFileName=/tmp/svnhooks_${dateTime}.log
  
# svn配置
REPOS="$1"
REV="$2"
  
# 检出或者更新subversion,钩子的核心功能
echo  "-- $dateTimeMinute" >> $logFileName
if [ ! -d $dirHtmlApp/.svn ]; then
   # 检出SVN
   echo "$binSvn co file://$REPOS/  $dirHtmlApp" >> $logFileName
   $binSvn co file://$REPOS/  $dirHtmlApp
   if [ $? -eq 0 ]; then
      echo  "checkout ok"  >> $logFileName
   else
      echo  "checkout error"   >>  $logFileName
   fi
else
   # 更新svn
   echo " $binSvn up $REV $dirHtmlApp " >> $logFileName
   $binSvn up $REV $dirHtmlApp   >> $logFileName
   if [ $? -eq 0 ]; then
       echo  "  update sucess "  >> $logFileName
   else
       echo  "  update fial "   >>  $logFileName
   fi
fi
echo  "--" >>  $logFileName

你可能感兴趣的:(svn钩子)