1717# ======================================================================
1818# 1. 下载或更新spring-boot-plus版本库
1919# 2. maven打包
20- # 3. 运行spring-boot-plus
21- # 4. 访问项目
20+ # 3. 停服
21+ # 4. 备份
22+ # 5. 运行spring-boot-plus
2223# author: geekidea
2324# date: 2020-3-25
2425# ======================================================================
@@ -27,16 +28,28 @@ NOW=$(date --date='0 days ago' "+%Y-%m-%d-%H-%M-%S")
2728echo " ${NOW} "
2829PULL_RESULT=" "
2930IS_UPDATE=0
31+ # 项目名称
32+ PROJECT_NAME=" spring-boot-plus"
33+ # 版本库路径
34+ REPO_URL=" https://gitee.com/geekidea/spring-boot-plus.git"
35+ # 打包文件名称
36+ ASSEMBLY_NAME=" spring-boot-plus-server-2.0.tar.gz"
37+ # 服务目录名称
38+ SERVER_DIR=" spring-boot-plus-server-2.0"
39+ # 发布的GIT分支名称
40+ DEPLOY_BRANCH=dev
41+ # 发布的Maven Profile
42+ ACTIVE_PROFILE=test
3043
3144# 1. 下载或更新spring-boot-plus版本库
3245# 先判断当前目录下是否有spring-boot-plus目录
3346# 如果有,则执行git pull
3447# 如果没有,则clone
35- if [ ! -d " spring-boot-plus " ]; then
36- git clone https://gitee.com/geekidea/spring-boot-plus.git
37- cd spring-boot-plus
48+ if [ ! -d " ${PROJECT_NAME} " ]; then
49+ git clone ${REPO_URL}
50+ cd ${PROJECT_NAME}
3851else
39- cd spring-boot-plus
52+ cd ${PROJECT_NAME}
4053 # 拉取代码,并获取结果判断,是否有新的代码更新,如果有,则备份之前的server,否则替换
4154 PULL_RESULT=$( git pull)
4255 echo " ${PULL_RESULT} "
5063
5164pwd
5265
53-
54- git checkout master
55-
66+ git checkout ${DEPLOY_BRANCH}
5667git branch
5768
5869# 2. maven打包
59- mvn clean install -P release,test
60- mvn clean package -P release,test
70+ mvn clean install -P release,${ACTIVE_PROFILE}
71+ mvn clean package -P release,${ACTIVE_PROFILE}
6172
6273pwd
6374# 判断是否生成成功
64- if [ ! -f " target/spring-boot-plus-server-assembly.tar.gz " ]; then
75+ if [ ! -f " distribution/ target/${ASSEMBLY_NAME} " ]; then
6576 echo " maven build fail"
6677 exit
6778fi
7081cd ..
7182pwd
7283
73- if [ -d " spring-boot-plus-server " ]; then
74- sh spring-boot-plus-server /bin/shutdown.sh
84+ if [ -d " ${SERVER_DIR} " ]; then
85+ sh ${SERVER_DIR} /bin/shutdown.sh
7586fi
7687
7788# 4. 复制spring-boot-plus-server-assembly.tar.gz到项目同级目录下
7889# 备份之前的server
7990
80- if [ ! -d " spring-boot-plus-server -back" ]; then
81- mkdir spring-boot-plus-server -back
91+ if [ ! -d " ${SERVER_DIR} -back" ]; then
92+ mkdir ${SERVER_DIR} -back
8293fi
8394
8495if [[ $IS_UPDATE == 1 ]]
8596then
86- echo " back spring-boot-plus-server ..."
87- mv spring-boot-plus-server spring-boot-plus-server- back/spring-boot-plus-server -back-" ${NOW} "
97+ echo " back ${SERVER_DIR} ..."
98+ mv ${SERVER_DIR} ${SERVER_DIR} - back/${SERVER_DIR} -back-" ${NOW} "
8899 echo " back success"
89100fi
90101
91- echo " copy spring-boot-plus-server-assembly.tar.gz ..."
102+ echo " copy ${ASSEMBLY_NAME} ..."
92103# 复制到项目同级目录,如果有,则覆盖
93- cp -r -f spring-boot-plus/ target/spring-boot-plus-server-assembly.tar.gz spring-boot-plus-server-assembly.tar.gz
104+ cp -r -f ${PROJECT_NAME} /distribution/ target/${ASSEMBLY_NAME} ${ASSEMBLY_NAME}
94105echo " copy success"
95106
96107pwd
97108# 5. 运行spring-boot-plus
98- tar -zxvf spring-boot-plus-server-assembly.tar.gz
109+ tar -zxvf ${ASSEMBLY_NAME}
99110echo " tar.gz decompression success"
100111
101112pwd
102- sh spring-boot-plus-server /bin/shutdown.sh
103- sh spring-boot-plus-server /bin/startup.sh
113+ sh ${SERVER_DIR} /bin/shutdown.sh
114+ sh ${SERVER_DIR} /bin/startup.sh
104115
0 commit comments