shell脚本模板-从git拉取代码并打包部署

发布时间 2023-12-12 15:17:23作者: 裸奔到月球
source /etc/profile
. ~/.bash_profile
# 拉取能耗后端代码
cd /usr/local/test
mvn clean
echo -e "从git华为云拉取后端代码"
# 首次clone
git pull test.git
echo -e "从git华为云代码拉取完成"

# 工程打包
echo -e "开始打jar包"
mvn package -Dmaven.test.skip=true
# 删除原来的jar包
rm -rf test.jar
# 复制jar到新路径下
cp ./target/test.jar ../new/test
echo -e "jar包完成打包"

# 工程部署
# 先杀掉该jar的服务
tpid=`ps -ef|grep "test.jar"|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
kill -9 $tpid
fi
cd /usr/local/new/test
nohup java -jar test.jar &