Shell脚本-自动化部署WEB

#! /bin/bashif [ $# -ne 1 ]
then
    echo "#### 参数有误,$1:构建号必填"
exit 1
fi

cd /root/workspace/xinya_erp/xinya_web
git checkout developer
git fetch --all 
git reset --hard origin/master
git pull
docker rm -f xinyar_erp_web_test
cd /root/workspace/xinya_erp/
mvn install
cd xinya_web/
#构建Docker镜像
mvn clean  package docker:build
docker run --restart=always -d -p 8091:8091 --name xinyar_erp_web_test  xinyar/erp-web:v$1
cd  /root/workspace/xinya_erp/
sh apidoc.sh
rm -rf /data/nginx/html/apidoc/
cp -R  /root/workspace/xinya_erp/xinya_web/apidoc/  /data/nginx/html/apidoc/
rm -rf /root/workspace/xinya_erp/xinya_web/apidoc/

 

Jenkins执行调用该脚本,如下:

Spring Boot2.0:使用Docker部署Spring Boot

Gitlab利用Webhook实现Push代码后的Jenkins自动构建

 

原文地址:https://www.cnblogs.com/linjiqin/p/10496065.html