Browse Source

Актуализация обновления

Tomishinets Vladimir 3 years ago
parent
commit
effcf412d7
1 changed files with 41 additions and 41 deletions
  1. 41 41
      updateK8s.Jenkinsfile

+ 41 - 41
updateK8s.Jenkinsfile

@@ -1,5 +1,5 @@
-@Library('jenkins-library@master') _
-def Label = "analis-lab-build-${UUID.randomUUID().toString()}"
+@Library('jenkins-library-iru@master') _
+def Label = "analis-lab-update-${UUID.randomUUID().toString()}"
 pipeline {
   options {
     buildDiscarder logRotator(numToKeepStr: '10')
@@ -13,13 +13,11 @@ pipeline {
     }
   }
   environment {
-    CLOUD='cloud-it-k8s'
-    DOCKER_IMAGE='lab/analis'
-    CHART_SUBPATH='helm/analis'
-    NAMESPACE='analis'
+    CONTEXT='provision@sdsys.office'
+    DOCKER_IMAGE='web-laboratory/analis'
     HELM_GIT_URL='ssh://git@git.sdsys.ru:8022/labportal/k8s.git'
     JENKINS_MAIL='jenkins.dev@sdsys.ru'
-    DOCKER_REGISTRY='jcr.infoclinica.ru'
+    DOCKER_REGISTRY='images.sdsys.ru'
     CHART_NAME=''
     CHART_PATH=''
     PROJECT=''
@@ -40,8 +38,9 @@ pipeline {
           echo "Pull Repo"
           gitOps.clone(HELM_GIT_URL)
           HELM_DIR = dirOps.calculateDir(HELM_GIT_URL)
-          CHART_PATH = "${HELM_DIR}/${CHART_SUBPATH}"
-          PROJECT = DOCKER_IMAGE.split("/")[1]
+          CHART_PATH = "helm/" + DOCKER_IMAGE.split("/")[0]
+          VALUES_FILE_DEV = HELM_DIR + "/helm/" + "dev-" + DOCKER_IMAGE.split("/")[1] + ".yaml"
+          VALUES_FILE_PROD = HELM_DIR + "/helm/" + "dev-" + DOCKER_IMAGE.split("/")[1] + ".yaml"
         }
       }
     }
@@ -49,50 +48,51 @@ pipeline {
       steps {
         script {
           echo "Update values.yaml"
-          def data = readYaml file: "${CHART_PATH}/values.yaml"
-          TAG_PATH = "images.${PROJECT}.build"
-          TAG = yamlOps.getBuilder(TAG_PATH, data)
-          TAG_PATH = "images.${PROJECT}.stable"
-          yamlOps.updateBuilder(TAG_PATH, data, TAG)
+          def data = readYaml file: VALUES_FILE_DEV
+          TAG_PATH_BUILD = "images." + DOCKER_IMAGE.split("/")[1] + ".build"
+          TAG = yamlOps.getBuilder(TAG_PATH_BUILD, data)
+          def data = readYaml file: VALUES_FILE_PROD
+          TAG_PATH_STABLE = "images." + DOCKER_IMAGE.split("/")[1] + ".stable"
+          yamlOps.updateBuilder(TAG_PATH_STABLE, data, TAG)
           writeYaml file: "${CHART_PATH}/values.yaml", data: data, overwrite: true
         }
       }
     }
-    stage("Update APP") {
-      steps {
-        script {
-          RELEASENAME = CHART_SUBPATH.split("/")[1]
-          try {
-            echo "Update APP"
-            k8sHelmOps.upgrade(CLOUD, NAMESPACE, RELEASENAME, CHART_PATH, 'dev')
-          }
-          catch(err) {
-            echo "Recovering APP"
-            k8sHelmOps.rollback(CLOUD, NAMESPACE, RELEASENAME)
-            throw err
-          }
-        }
-      }
-    }
+    // stage("Update APP") {
+    //   steps {
+    //     script {
+    //       RELEASENAME = CHART_SUBPATH.split("/")[1]
+    //       try {
+    //         echo "Update APP"
+    //         k8sHelmOps.upgrade(CLOUD, NAMESPACE, RELEASENAME, CHART_PATH, 'dev')
+    //       }
+    //       catch(err) {
+    //         echo "Recovering APP"
+    //         k8sHelmOps.rollback(CLOUD, NAMESPACE, RELEASENAME)
+    //         throw err
+    //       }
+    //     }
+    //   }
+    // }
     stage("Push changes to REPO") {
       steps {
         script {
           echo "Push changes to Repo"
-          COMMIT = "Version update ${PROJECT} to ${TAG}"
+          COMMIT = "Version update ${Laboratory} to ${TAG}"
           gitOps.push(HELM_DIR, COMMIT)
         }
       }
     }
-    stage("Tagging Image") {
-      steps {
-        script {
-          echo "Tagging ${TAG} to latest"
-          IMAGE = "${DOCKER_REGISTRY}/${DOCKER_IMAGE}"
-          k8sBuildImage.crane(IMAGE, TAG, 'latest')
-        }
-      }
-    }
-  }
+  //   stage("Tagging Image") {
+  //     steps {
+  //       script {
+  //         echo "Tagging ${TAG} to latest"
+  //         IMAGE = "${DOCKER_REGISTRY}/${DOCKER_IMAGE}"
+  //         k8sBuildImage.crane(IMAGE, TAG, 'latest')
+  //       }
+  //     }
+  //   }
+  // }
   post {
     failure {
       mail charset: 'UTF-8',