大致思路:
从git上clone源代码到本地;使用mvn package将源代码达成war/jar包;将打好的包放到tomcatpath/webapps/下;到tomcatpath/bin/下执行restart.sh脚本重启; 脚本:#!/bin/bash{flock -n 100[ $? -eq 1 ] && { echo -e "\033[41;1m wait for deploying... \033[0m"; exit; }echo "start to deploy..."SERVER_PATH=/data/server/merchant-server-8086WEBINF_PATH=$SERVER_PATH/webapps/merchant/WEB-INFSOURCE_PATH=/data/git/o2o-merchant-webTARGET_PATH=$SOURCE_PATH/targetCLASSES_PATH=$TARGET_PATH/merchant/WEB-INF/classesLIB_PATH=$TARGET_PATH/merchant/WEB-INF/libWAR_PATH=$TARGET_PATH/merchant.warTOMCAT_WAR_PATH=$SERVER_PATH/webappsrm -rf $SOURCE_PATHmkdir $SOURCE_PATHgit clone -b dev_vettingCredit git@git.wecash.net:o2o/o2o-merchant-web.git $SOURCE_PATHcd $SOURCE_PATH && mvn clean && mvn package -Ptest -Dmaven.test.skip=trueif [ ! -x "$TARGET_PATH/merchant" ]; thenecho -e "\033[41;1m mvn install failure, please check. \033[0m"exit;ficd $SERVER_PATH && ./bin/shutdown.shmv $TOMCAT_WAR_PATH/merchant.war $TOMCAT_WAR_PATH/merchant.war_backrm -rf $TOMCAT_WAR_PATH/merchantcp $WAR_PATH $TOMCAT_WAR_PATH/merchant.warcd $SERVER_PATH && ./bin/restart.shflock -u 100} 100<>~/.deploy_merchant_lock