大致思路:
从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-8086 WEBINF_PATH=$SERVER_PATH/webapps/merchant/WEB-INF SOURCE_PATH=/data/git/o2o-merchant-web TARGET_PATH=$SOURCE_PATH/target CLASSES_PATH=$TARGET_PATH/merchant/WEB-INF/classes LIB_PATH=$TARGET_PATH/merchant/WEB-INF/lib WAR_PATH=$TARGET_PATH/merchant.war TOMCAT_WAR_PATH=$SERVER_PATH/webapps rm -rf $SOURCE_PATH mkdir $SOURCE_PATH git clone -b dev_vettingCredit [email protected]:o2o/o2o-merchant-web.git $SOURCE_PATH cd $SOURCE_PATH && mvn clean && mvn package -Ptest -Dmaven.test.skip=true if [ ! -x "$TARGET_PATH/merchant" ]; then echo -e "\033[41;1m mvn install failure, please check. \033[0m" exit; fi cd $SERVER_PATH && ./bin/shutdown.sh mv $TOMCAT_WAR_PATH/merchant.war $TOMCAT_WAR_PATH/merchant.war_back rm -rf $TOMCAT_WAR_PATH/merchant cp $WAR_PATH $TOMCAT_WAR_PATH/merchant.war cd $SERVER_PATH && ./bin/restart.sh flock -u 100 } 100<>~/.deploy_merchant_lock
原文地址:https://www.cnblogs.com/peanutk/p/8494185.html
时间: 2024-10-09 22:26:07