chencheng vor 1 Jahr
Ursprung
Commit
897fa0a860
1 geänderte Dateien mit 28 neuen und 3 gelöschten Zeilen
  1. 28 3
      deploy/Jenkinsfile

+ 28 - 3
deploy/Jenkinsfile

@@ -8,6 +8,7 @@ pipeline {
 
   environment {
     IMAGE_REPO = "SXKJ:32775"
+    IMAGE_REPO_YILI = "registry.cn-hangzhou.aliyuncs.com/sxtest"
     TAB = "\n   \n  "
     GIT_LOG = sh (script: "git log --oneline -n 1", returnStdout: true).trim()
     BUILD_USER_NAME = sh(script: "git log -1 --pretty=format:'%an'", returnStdout: true).trim()
@@ -29,7 +30,15 @@ pipeline {
       steps {
         container('docker') {
           echo "构建 Docker 镜像阶段"
-          sh 'docker build  -t ${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG} --output type=docker .'
+          sh '''
+          if [ "$ENV_APP" == "yili-dxy" ]; then
+            docker build  -t ${IMAGE_REPO_YILI}/${JOB_BASE_NAME}:${TAG} --output type=docker .
+          elif [ "$ENV_APP" == "test" ]; then
+            docker build  -t ${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG} --output type=docker .
+          else
+            xxx
+          fi
+          '''
           echo "build success"
         }
         script {
@@ -41,7 +50,15 @@ pipeline {
       steps {
         container('docker') {
           echo "Push Docker 镜像阶段"
-          sh 'docker push ${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG}'
+          sh '''
+          if [ "$ENV_APP" == "test" ]; then
+            docker push ${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG}
+          elif [ "$ENV_APP" == "yili-dxy" ]; then
+            docker push ${IMAGE_REPO_YILI}/${JOB_BASE_NAME}:${TAG}
+          else
+            xxx
+          fi
+          '''
           echo "Push image success"
         }
         script {
@@ -52,7 +69,15 @@ pipeline {
     stage('重启服务') {
       steps {
         container('kubectl') {
-          sh '[[ "$ENV_APP" == "test" ]] && kubectl set image deployment/ocr-table table=${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG} --namespace yili-ocr --kubeconfig kubeconfig-sxkj ||  kubectl set image deployment/ocr-table table=${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG} --namespace yili-ocr  --kubeconfig kubeconfig-sxkjprod'
+          sh '''
+          if [ "$ENV_APP" == "test" ]; then
+            kubectl set image deployment/ocr-table table=${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG} --namespace yili-ocr --kubeconfig kubeconfig-sxkj ||  kubectl set image deployment/ocr-table table=${IMAGE_REPO}/${JOB_BASE_NAME}:${TAG} --namespace yili-ocr  --kubeconfig kubeconfig-sxkjprod
+          elif [ "$ENV_APP" == "yili-dxy" ]; then
+            echo "$ENV_APP"
+          else
+            xxx
+          fi
+          '''
         }
         script {
           env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB