#!/bin/bash
SRC=/home/userName/datas/svn/projectName/trunk
WAR=$SRC/target/projectNamei.war
TOMCAT=/home/userName/datas/webServers/tomcat8/tomcat_projectName
COMMAND=$TOMCAT/projectName.sh
WEBAPPS=$TOMCAT/webapps
cd $SRC
source /home/userName/.bashrc
svn update
mvn clean
mvn package -P dev
if [ -s $WAR ]; then
rm $WEBAPPS/* -rf
cp -rf $WAR $WEBAPPS/
$COMMAND restart
sleep 20
tail -n 500 $TOMCAT/logs/catalina.out
else
echo "package faild not find war"
set -e #注意,这句最重要,一定要先设置这个,非常感谢 诺亚舟 的提示
exit 1 #然后再退出,jenkins就会报红显示构建失败
fi