怪獣唻孒怎庅刅 1 месяц назад
Родитель
Сommit
252d762c6e
1 измененных файлов с 97 добавлено и 34 удалено
  1. 97 34
      .drone.yml

+ 97 - 34
.drone.yml

@@ -1,4 +1,10 @@
-#########################################################################################################
+###################################################################################################################################################
+#                                                                                                                                                 #
+#                                                                                                                                                 #
+#                                                                                                                                                 #
+#                                                                                                                                                 #
+###################################################################################################################################################
+# 生产环境配置
 # 1.打包构建release-lhb-gateway
 kind: pipeline
 type: docker
@@ -23,6 +29,9 @@ volumes:
   - name: docker-socket
     host:
       path: /var/run/docker.sock
+  - name: delpoyment
+    host:
+      path: /home/ABServer/drone/config/shell 
 
 clone:
   disable: false
@@ -58,9 +67,10 @@ steps:
       - cp -v lhb-gateway/target/*.jar /context/
       - cp -rv lhb-gateway/target/lib /context/
       - cp -rv lhb-gateway/target/config /context/
-      - cp /dockerfiles/template-prod.dockerfile /context/Dockerfile
+      - cp /dockerfiles/template-example.dockerfile /context/Dockerfile
       - sed -i 's/{Xms}/1024m/g' /context/Dockerfile
       - sed -i 's/{Xmx}/1024m/g' /context/Dockerfile
+      - sed -i 's/{Env}/prod/g' /context/Dockerfile
       - sed -i 's/{ImageName}/lhb-gateway/g' /context/Dockerfile
       - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
       - ls -alR /context
@@ -76,18 +86,24 @@ steps:
         path: /etc/localtime
       - name: docker-socket
         path: /var/run/docker.sock
+      - name: delpoyment
+        path: /home
     environment:
       HARBOR_USER:
         from_secret: harbor_robot
       HARBOR_PASS:
         from_secret: harbor_token
     commands:
-      - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - cd /context
       - TAG=prod-$(date +%Y%m%d%H%M%S)-${DRONE_COMMIT_SHA:0:10}
+      - TAG_FILE="/home/${DRONE_BUILD_NUMBER}.txt"
+      - echo "$TAG" > "$TAG_FILE"
+      - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - docker build -t "harbor.kexiaoshuang.com/laihaoba/lhb-gateway:$TAG" .
       - docker push "harbor.kexiaoshuang.com/laihaoba/lhb-gateway:$TAG"
       - docker rmi "harbor.kexiaoshuang.com/laihaoba/lhb-gateway:$TAG"
+      - echo "TAG_FILE=$TAG_FILE"
+      - cat "$TAG_FILE"
 
 trigger:
   event: [ push ]
@@ -120,6 +136,9 @@ volumes:
   - name: docker-socket
     host:
       path: /var/run/docker.sock
+  - name: delpoyment
+    host:
+      path: /home/ABServer/drone/config/shell 
 
 clone:
   disable: false
@@ -155,9 +174,10 @@ steps:
       - cp -v lhb-quartz/target/*.jar /context/
       - cp -rv lhb-quartz/target/lib /context/
       - cp -rv lhb-quartz/target/config /context/
-      - cp /dockerfiles/template-prod.dockerfile /context/Dockerfile
+      - cp /dockerfiles/template-example.dockerfile /context/Dockerfile
       - sed -i 's/{Xms}/512m/g' /context/Dockerfile
       - sed -i 's/{Xmx}/512m/g' /context/Dockerfile
+      - sed -i 's/{Env}/prod/g' /context/Dockerfile
       - sed -i 's/{ImageName}/lhb-quartz/g' /context/Dockerfile
       - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
       - ls -alR /context
@@ -173,18 +193,24 @@ steps:
         path: /etc/localtime
       - name: docker-socket
         path: /var/run/docker.sock
+      - name: delpoyment
+        path: /home
     environment:
       HARBOR_USER:
         from_secret: harbor_robot
       HARBOR_PASS:
         from_secret: harbor_token
     commands:
-      - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - cd /context
       - TAG=prod-$(date +%Y%m%d%H%M%S)-${DRONE_COMMIT_SHA:0:10}
+      - TAG_FILE="/home/${DRONE_BUILD_NUMBER}.txt"
+      - echo "$TAG" > "$TAG_FILE"
+      - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - docker build -t "harbor.kexiaoshuang.com/laihaoba/lhb-quartz:$TAG" .
       - docker push "harbor.kexiaoshuang.com/laihaoba/lhb-quartz:$TAG"
       - docker rmi "harbor.kexiaoshuang.com/laihaoba/lhb-quartz:$TAG"
+      - echo "TAG_FILE=$TAG_FILE"
+      - cat "$TAG_FILE"
 
 trigger:
   event: [ push ]
@@ -218,6 +244,9 @@ volumes:
   - name: docker-socket
     host:
       path: /var/run/docker.sock
+  - name: delpoyment
+    host:
+      path: /home/ABServer/drone/config/shell 
 
 clone:
   disable: false
@@ -253,10 +282,11 @@ steps:
       - cp -v lhb-system/lhb-system-biz/target/*.jar /context/
       - cp -rv lhb-system/lhb-system-biz/target/lib /context/
       - cp -rv lhb-system/lhb-system-biz/target/config /context/
-      - cp /dockerfiles/template-biz-prod.dockerfile /context/Dockerfile
+      - cp /dockerfiles/template-example.dockerfile /context/Dockerfile
       - sed -i 's/{Xms}/512m/g' /context/Dockerfile
       - sed -i 's/{Xmx}/512m/g' /context/Dockerfile
-      - sed -i 's/{ImageName}/lhb-system/g' /context/Dockerfile
+      - sed -i 's/{Env}/prod/g' /context/Dockerfile
+      - sed -i 's/{ImageName}/lhb-system-biz/g' /context/Dockerfile 
       - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
       - echo "===== 构建上下文文件列表 ====="
       - ls -laR /context
@@ -272,18 +302,24 @@ steps:
         path: /etc/localtime
       - name: docker-socket
         path: /var/run/docker.sock
+      - name: delpoyment
+        path: /home
     environment:
       HARBOR_USER:
         from_secret: harbor_robot
       HARBOR_PASS:
         from_secret: harbor_token
     commands:
-      - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - cd /context
       - TAG=prod-$(date +%Y%m%d%H%M%S)-${DRONE_COMMIT_SHA:0:10}
+      - TAG_FILE="/home/${DRONE_BUILD_NUMBER}.txt"
+      - echo "$TAG" > "$TAG_FILE"
+      - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - docker build -t "harbor.kexiaoshuang.com/laihaoba/lhb-system:$TAG" .
       - docker push "harbor.kexiaoshuang.com/laihaoba/lhb-system:$TAG"
       - docker rmi "harbor.kexiaoshuang.com/laihaoba/lhb-system:$TAG"
+      - echo "TAG_FILE=$TAG_FILE"
+      - cat "$TAG_FILE"
 
 trigger:
   event: [ push ]
@@ -353,10 +389,11 @@ steps:
       - cp -v lhb-basic/lhb-basic-biz/target/*.jar /context/
       - cp -rv lhb-basic/lhb-basic-biz/target/lib /context/
       - cp -rv lhb-basic/lhb-basic-biz/target/config /context/
-      - cp /dockerfiles/template-biz-prod.dockerfile /context/Dockerfile
+      - cp /dockerfiles/template-example.dockerfile /context/Dockerfile
       - sed -i 's/{Xms}/512m/g' /context/Dockerfile
       - sed -i 's/{Xmx}/512m/g' /context/Dockerfile
-      - sed -i 's/{ImageName}/lhb-basic/g' /context/Dockerfile
+      - sed -i 's/{Env}/prod/g' /context/Dockerfile
+      - sed -i 's/{ImageName}/lhb-basic-biz/g' /context/Dockerfile
       - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
       - echo "===== 构建上下文文件列表 ====="
       - ls -laR /context
@@ -372,18 +409,24 @@ steps:
         path: /etc/localtime
       - name: docker-socket
         path: /var/run/docker.sock
+      - name: delpoyment
+        path: /home
     environment:
       HARBOR_USER:
         from_secret: harbor_robot
       HARBOR_PASS:
         from_secret: harbor_token
     commands:
-      - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - cd /context
       - TAG=prod-$(date +%Y%m%d%H%M%S)-${DRONE_COMMIT_SHA:0:10}
+      - TAG_FILE="/home/${DRONE_BUILD_NUMBER}.txt"
+      - echo "$TAG" > "$TAG_FILE"
+      - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - docker build -t "harbor.kexiaoshuang.com/laihaoba/lhb-basic:$TAG" .
       - docker push "harbor.kexiaoshuang.com/laihaoba/lhb-basic:$TAG"
       - docker rmi "harbor.kexiaoshuang.com/laihaoba/lhb-basic:$TAG"
+      - echo "TAG_FILE=$TAG_FILE"
+      - cat "$TAG_FILE"
 
 trigger:
   event: [ push ]
@@ -460,9 +503,10 @@ steps:
       - cp -v lhb-gateway/target/*.jar /context/
       - cp -rv lhb-gateway/target/lib /context/
       - cp -rv lhb-gateway/target/config /context/
-      - cp /dockerfiles/template-test.dockerfile /context/Dockerfile
+      - cp /dockerfiles/template-example.dockerfile /context/Dockerfile
       - sed -i 's/{Xms}/512m/g' /context/Dockerfile
       - sed -i 's/{Xmx}/512m/g' /context/Dockerfile
+      - sed -i 's/{Env}/test/g' /context/Dockerfile
       - sed -i 's/{ImageName}/lhb-gateway/g' /context/Dockerfile
       - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
       - ls -alR /context
@@ -488,11 +532,14 @@ steps:
     commands:
       - cd /context
       - TAG=test-$(date +%Y%m%d%H%M%S)-${DRONE_COMMIT_SHA:0:10}
-      - echo "$TAG" > /home/TAG.txt
+      - TAG_FILE="/home/${DRONE_BUILD_NUMBER}.txt"
+      - echo "$TAG" > "$TAG_FILE" 
       - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - docker build -t "harbor.kexiaoshuang.com/test/lhb-gateway:$TAG" .
       - docker push "harbor.kexiaoshuang.com/test/lhb-gateway:$TAG"
       - docker rmi "harbor.kexiaoshuang.com/test/lhb-gateway:$TAG"
+      - echo "TAG_FILE=$TAG_FILE"
+      - cat "$TAG_FILE"
 
   # 阶段四:测试环境部署服务
   - name: trigger-deploy
@@ -502,10 +549,11 @@ steps:
       - name: delpoyment
         path: /shared
     commands:
-      - TAG=$(cat /shared/TAG.txt)
+      - TAG_FILE="/shared/${DRONE_BUILD_NUMBER}.txt"
+      - test -f "$TAG_FILE"
+      - TAG=$(cat "$TAG_FILE")
       - echo "TAG=$TAG"
-      - cd /shared
-      - sh /shared/trigger-deploy.sh $TAG lhb-gateway laihaoba
+      - sh /shared/trigger-deploy-omega.sh $TAG lhb-gateway laihaoba test-cluster
 
 
 trigger:
@@ -577,9 +625,10 @@ steps:
       - cp -v lhb-quartz/target/*.jar /context/
       - cp -rv lhb-quartz/target/lib /context/
       - cp -rv lhb-quartz/target/config /context/
-      - cp /dockerfiles/template-test.dockerfile /context/Dockerfile
+      - cp /dockerfiles/template-example.dockerfile /context/Dockerfile
       - sed -i 's/{Xms}/256m/g' /context/Dockerfile
       - sed -i 's/{Xmx}/256m/g' /context/Dockerfile
+      - sed -i 's/{Env}/test/g' /context/Dockerfile
       - sed -i 's/{ImageName}/lhb-quartz/g' /context/Dockerfile
       - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
       - echo "=============构建上下文文件列表==============="
@@ -606,11 +655,14 @@ steps:
     commands:
       - cd /context
       - TAG=test-$(date +%Y%m%d%H%M%S)-${DRONE_COMMIT_SHA:0:10}
-      - echo "$TAG" > /home/TAG.txt
+      - TAG_FILE="/home/${DRONE_BUILD_NUMBER}.txt"
+      - echo "$TAG" > "$TAG_FILE"
       - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - docker build -t "harbor.kexiaoshuang.com/test/lhb-quartz:$TAG" .
       - docker push "harbor.kexiaoshuang.com/test/lhb-quartz:$TAG"
       - docker rmi "harbor.kexiaoshuang.com/test/lhb-quartz:$TAG"
+      - echo "TAG_FILE=$TAG_FILE"
+      - cat "$TAG_FILE"
 
   # 阶段四:测试环境部署服务
   - name: trigger-deploy
@@ -620,10 +672,11 @@ steps:
       - name: delpoyment
         path: /shared
     commands:
-      - TAG=$(cat /shared/TAG.txt)
+      - TAG_FILE="/shared/${DRONE_BUILD_NUMBER}.txt"
+      - test -f "$TAG_FILE"
+      - TAG=$(cat "$TAG_FILE")
       - echo "TAG=$TAG"
-      - cd /shared
-      - sh /shared/trigger-deploy.sh $TAG lhb-quartz laihaoba
+      - sh /shared/trigger-deploy-omega.sh $TAG lhb-quartz laihaoba test-cluster
 
 
 trigger:
@@ -695,10 +748,11 @@ steps:
       - cp -v lhb-system/lhb-system-biz/target/*.jar /context/
       - cp -rv lhb-system/lhb-system-biz/target/lib /context/
       - cp -rv lhb-system/lhb-system-biz/target/config /context/
-      - cp /dockerfiles/template-biz-test.dockerfile /context/Dockerfile
+      - cp /dockerfiles/template-example.dockerfile /context/Dockerfile
       - sed -i 's/{Xms}/512m/g' /context/Dockerfile
       - sed -i 's/{Xmx}/512m/g' /context/Dockerfile
-      - sed -i 's/{ImageName}/lhb-system/g' /context/Dockerfile
+      - sed -i 's/{Env}/test/g' /context/Dockerfile
+      - sed -i 's/{ImageName}/lhb-system-biz/g' /context/Dockerfile 
       - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
       - echo "===== 构建上下文文件列表 ====="
       - ls -laR /context
@@ -722,13 +776,16 @@ steps:
       HARBOR_PASS:
         from_secret: harbor_token
     commands:
-      - cd /context
+      -- cd /context
       - TAG=test-$(date +%Y%m%d%H%M%S)-${DRONE_COMMIT_SHA:0:10}
-      - echo "$TAG" > /home/TAG.txt
+      - TAG_FILE="/home/${DRONE_BUILD_NUMBER}.txt"
+      - echo "$TAG" > "$TAG_FILE" 
       - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - docker build -t "harbor.kexiaoshuang.com/test/lhb-system:$TAG" .
       - docker push "harbor.kexiaoshuang.com/test/lhb-system:$TAG"
       - docker rmi "harbor.kexiaoshuang.com/test/lhb-system:$TAG"
+      - echo "TAG_FILE=$TAG_FILE"
+      - cat "$TAG_FILE"
 
   # 阶段四:测试环境部署服务
   - name: trigger-deploy
@@ -738,10 +795,11 @@ steps:
       - name: delpoyment
         path: /shared
     commands:
-      - TAG=$(cat /shared/TAG.txt)
+      - TAG_FILE="/shared/${DRONE_BUILD_NUMBER}.txt"
+      - test -f "$TAG_FILE"
+      - TAG=$(cat "$TAG_FILE")
       - echo "TAG=$TAG"
-      - cd /shared
-      - sh /shared/trigger-deploy.sh $TAG lhb-system laihaoba 
+      - sh /shared/trigger-deploy-omega.sh $TAG lhb-system laihaoba test-cluster
 
 trigger:
   event: [ push ]
@@ -814,10 +872,11 @@ steps:
       - cp -v lhb-basic/lhb-basic-biz/target/*.jar /context/
       - cp -rv lhb-basic/lhb-basic-biz/target/lib /context/
       - cp -rv lhb-basic/lhb-basic-biz/target/config /context/
-      - cp /dockerfiles/template-biz-test.dockerfile /context/Dockerfile
+      - cp /dockerfiles/template-example.dockerfile /context/Dockerfile
       - sed -i 's/{Xms}/512m/g' /context/Dockerfile
       - sed -i 's/{Xmx}/512m/g' /context/Dockerfile
-      - sed -i 's/{ImageName}/lhb-basic/g' /context/Dockerfile
+      - sed -i 's/{Env}/test/g' /context/Dockerfile
+      - sed -i 's/{ImageName}/lhb-basic-biz/g' /context/Dockerfile
       - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
       - echo "===== 构建上下文文件列表 ====="
       - ls -laR /context
@@ -843,11 +902,14 @@ steps:
     commands:
       - cd /context
       - TAG=test-$(date +%Y%m%d%H%M%S)-${DRONE_COMMIT_SHA:0:10}
-      - echo "$TAG" > /home/TAG.txt
+      - TAG_FILE="/home/${DRONE_BUILD_NUMBER}.txt"
+      - echo "$TAG" > "$TAG_FILE" 
       - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
       - docker build -t "harbor.kexiaoshuang.com/test/lhb-basic:$TAG" .
       - docker push "harbor.kexiaoshuang.com/test/lhb-basic:$TAG"
       - docker rmi "harbor.kexiaoshuang.com/test/lhb-basic:$TAG"
+      - echo "TAG_FILE=$TAG_FILE"
+      - cat "$TAG_FILE"
 
   # 阶段四:测试环境部署服务
   - name: trigger-deploy
@@ -857,10 +919,11 @@ steps:
       - name: delpoyment
         path: /shared
     commands:
-      - TAG=$(cat /shared/TAG.txt)
+      - TAG_FILE="/shared/${DRONE_BUILD_NUMBER}.txt"
+      - test -f "$TAG_FILE"
+      - TAG=$(cat "$TAG_FILE")
       - echo "TAG=$TAG"
-      - cd /shared
-      - sh /shared/trigger-deploy.sh $TAG lhb-basic laihaoba
+      - sh /shared/trigger-deploy-omega.sh $TAG lhb-basic laihaoba test-cluster
 
 trigger:
   event: [ push ]