Tomishinets Vladimir vor 4 Jahren
Ursprung
Commit
ba2df1cd3a
1 geänderte Dateien mit 15 neuen und 13 gelöschten Zeilen
  1. 15 13
      prodK8s.Jenkinsfile

+ 15 - 13
prodK8s.Jenkinsfile

@@ -1,9 +1,10 @@
 @Library('jenkins-library@master') _
-def Label = "admin-build-${UUID.randomUUID().toString()}"
+def Label = "node-iru-build-${UUID.randomUUID().toString()}"
 pipeline {
   options {
     buildDiscarder logRotator(numToKeepStr: '10')
     disableConcurrentBuilds()
+    timeout(time: 10, unit: 'MINUTES')
   }
   agent {
     kubernetes {
@@ -14,14 +15,15 @@ pipeline {
   environment {
     CLOUD='cloud-it-k8s'
     DOCKER_IMAGE='iru/node'
-    CHART_PATH='helm/info'
+    CHART_SUBPATH='helm/info'
     NAMESPACE='info'
     HELM_GIT_URL='ssh://git@git.sdsys.ru:8022/iru/k8s.git'
     APP_GIT_URL='ssh://git@git.sdsys.ru:8022/iru/node.git'
     JENKINS_MAIL='jenkins.dev@sdsys.ru'
     DOCKER_REGISTRY='jcr.infoclinica.ru'
     CHART_NAME=''
-    APP_DIR=''
+    CHART_PATH=''
+    PROJECT=''
     HELM_DIR=''
     TAG=''
   }
@@ -39,6 +41,8 @@ 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]
         }
       }
     }
@@ -46,28 +50,26 @@ pipeline {
       steps {
         script {
           echo "Update values.yaml"
-          APP_DIR = dirOps.calculateDir(APP_GIT_URL)
-          def data = readYaml file: "${HELM_DIR}/${CHART_PATH}/values.yaml"
-          TAG_PATH = "images.${APP_DIR}.dev"
+          def data = readYaml file: "${CHART_PATH}/values.yaml"
+          TAG_PATH = "images.${PROJECT}.dev"
           TAG = yamlOps.getBuilder(TAG_PATH, data)
-          TAG_PATH = "images.${APP_DIR}.prod"
+          TAG_PATH = "images.${PROJECT}.prod"
           yamlOps.updateBuilder(TAG_PATH, data, TAG)
-          writeYaml file: "${HELM_DIR}/${CHART_PATH}/values.yaml", data: data, overwrite: true
+          writeYaml file: "${CHART_PATH}/values.yaml", data: data, overwrite: true
         }
       }
     }
     stage("Update APP") {
       steps {
         script {
-          CHART = "${HELM_DIR}/${CHART_PATH}"
-          CHART_NAME = CHART_PATH.split("/")[1]
+          RELEASENAME = CHART_SUBPATH.split("/")[1]
           try {
             echo "Update APP"
-            k8sHelmOps.upgrade(CLOUD, NAMESPACE, CHART_NAME, CHART, 'prod')
+            k8sHelmOps.upgrade(CLOUD, NAMESPACE, RELEASENAME, CHART_PATH, 'dev')
           }
           catch(err) {
             echo "Recovering APP"
-            k8sHelmOps.rollback(CLOUD, NAMESPACE, CHART_NAME)
+            k8sHelmOps.rollback(CLOUD, NAMESPACE, RELEASENAME)
             throw err
           }
         }
@@ -77,7 +79,7 @@ pipeline {
       steps {
         script {
           echo "Push changes to Repo"
-          COMMIT = "Version update ${APP_DIR}"
+          COMMIT = "Version update ${PROJECT}"
           gitOps.push(HELM_DIR, COMMIT)
         }
       }