当前位置:   article > 正文

部署发布脚本:linux+git+maven_linux git maven 脚本部署

linux git maven 脚本部署

现在公司项目编译部署都已经界面化,但是万变不离其中。

备案下,部署项目经常用到。

(待优化******部署脚本,需要通用,工程仓库路径、类型,多实例部署都需要抽取,从外面传人)

=====================================================================================

#!/bin/sh


#指定部署目录,拉取git上最新的代码
cd /home/deploy/liuzeheng/smc-sociality-server
rm -rf smc-sociality
git clone git@10.10.76.42:smc-sociality.git
cd smc-sociality


#定义不同的部署环境 ,指定要部署的环境

serverTest=(10.10.76.14)
serverOnline=(10.13.94.28 10.16.0.213)


read -p "evn to deploy? input [test] or [online]:"  evn

if [ "$evn" == "test" ]; then   ss=${serverTest[*]}  profile=test; git checkout develop;
elif [ "$evn" == "online" ]; then   ss=${serverOnline[*]} profile=online; git checkout master;
else
  echo "input error! only accept [test] and [online]"
  exit 0
fi



#编译打包

mvn clean install -U -P$profile -Dmaven.test.skip



alias scp=scp

#分发编译好的包到相应的服务器,并启动服务(服务提供启动脚本:server.sh)
for server in ${ss[*]}
do
read -p "部署到$server 【c/n】   "  deployed

if [ "$deployed" == "c" ]; then


scp  smc-sociality-rest-server/target/smc-sociality-rest-server-1.0-SNAPSHOT-dist.zip smc@$server:/opt/smc/
ssh smc@$server "rm -rf /opt/smc/smc-sociality-rest-server/lib"
ssh smc@$server "cd /opt/smc; unzip -o -d smc-sociality-rest-server smc-sociality-rest-server-1.0-SNAPSHOT-dist.zip"
ssh smc@$server "cd /opt/smc; rm -rf smc-sociality-rest-server-1.0-SNAPSHOT-dist.zip"

ssh smc@$server "cd /opt/smc/smc-sociality-rest-server ; sh server.sh"


fi
done
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/130693
推荐阅读
相关标签
  

闽ICP备14008679号