#!/bin/bash
HOME_DIR="/home/localadmin/"
echo "git文件夹是"$HOME_DIR"dzy-all"
if [ ! -d $HOME_DIR"dzy-all" ];#如果不是一个文件夹
then
git config --global credential.helper store
if [ $# -ne 1 ]; then
echo "usage:sudo ./tomcat_update.sh branchname"
exit 0
fi
git clone -b $1 http://git.github.com/dzy_v3/dzy-all.git dzy-all
else
echo "git文件夹已存在,放行"
fi
TAR_DIR="/usr/local/apache-tomcat-8.0.20"
GIT_DIR=$HOME_DIR"dzy-all/"
BK_FILENAME=$BK_DIR"/dzy-all"`date +%Y%m%d%H%M%S`".tar.gz"
PUBLISH_DIR=$TAR_DIR"webapps"
cd $TAR_DIR
cd webapps
echo "备份一下原有war包文件"
mv dzy-web.war bk_dzy-web.tar.gz
cd $GIT_DIR
echo "正在服务器拉取代码........"
pwd
git pull
echo "正在打包代码 ..........."
cd dzy-parent
mvn clean install -Dmaven.test.skip=true
cd ../dzy-common
mvn clean install -Dmaven.test.skip=true
cd ../dzy-data
mvn clean install -Dmaven.test.skip=true
cd ../dzy-user
mvn clean install -Dmaven.test.skip=true
cd ../dzy-module-parent
mvn clean install -Dmaven.test.skip=true
cd ../dzy-platform
mvn clean install -Dmaven.test.skip=true
echo "mvn打包代码完毕 ..........."
#rm_cmd='rm -rf '$PUBLISH_DIR'/*'
cd $TAR_DIR #到tomcat里面去
./bin/shutdown.sh
echo "等待10秒钟 ..........."
sleep 10000
`rm -rf $PUBLISH_DIR/dzy-web*`
`cp -r $HOME_DIR"dzy-all/target/dzy-web.war" $PUBLISH_DIR`
echo "移动war包完毕 ..........."
./bin/start.sh
echo "tomcat启动完毕........."
git linux上自动化打包发布脚本
最新推荐文章于 2024-07-27 23:39:06 发布