Преглед на файлове

Обновить 'Jenkinsfile'

Vladimir Tomishinets преди 6 години
родител
ревизия
b281f1c127
променени са 1 файла, в които са добавени 24 реда и са изтрити 16 реда
  1. 24 16
      Jenkinsfile

+ 24 - 16
Jenkinsfile

@@ -49,31 +49,39 @@ pipeline {
             try{
               echo "Updating $item"
               if (repo == 'prod') {
-              sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
-                    export DOCKER_HOST=tcp://${CLUSTER_PROD}:2376 DOCKER_TLS_VERIFY=1
-                    docker service update $item --image ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${repo}-${BUILD_NUMBER}
-                 '''
+                withEnv(["service_name=${item}"]) {
+                  sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
+                        export DOCKER_HOST=tcp://${CLUSTER_PROD}:2376 DOCKER_TLS_VERIFY=1
+                        docker service update ${service_name} --image ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${repo}-${BUILD_NUMBER}
+                      '''
+                }
               }
               if (repo == 'dev') {
-              sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
-                    export DOCKER_HOST=tcp://${CLUSTER_DEV}:2376 DOCKER_TLS_VERIFY=1
-                    docker service update $item --image ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${repo}-${BUILD_NUMBER}
-                 '''
+                withEnv(["service_name=${item}"]) {
+                  sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
+                        export DOCKER_HOST=tcp://${CLUSTER_DEV}:2376 DOCKER_TLS_VERIFY=1
+                        docker service update ${service_name} --image ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${repo}-${BUILD_NUMBER}
+                     '''
+                }
               }
             }
             catch(err){
               echo "Recovering service $item"
               if (repo == 'prod') {
-              sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
-                    export DOCKER_HOST=tcp://${CLUSTER_PROD}:2376 DOCKER_TLS_VERIFY=1
-                    docker service rollback $item
-                 '''
+                withEnv(["service_name=${item}"]) {
+                  sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
+                        export DOCKER_HOST=tcp://${CLUSTER_PROD}:2376 DOCKER_TLS_VERIFY=1
+                        docker service rollback ${service_name}
+                     '''
+                }
               }
               if (repo == 'dev') {
-              sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
-                    export DOCKER_HOST=tcp://${CLUSTER_DEV}:2376 DOCKER_TLS_VERIFY=1
-                    docker service rollback $item
-                 '''
+                withEnv(["service_name=${item}"]) {
+                  sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
+                        export DOCKER_HOST=tcp://${CLUSTER_DEV}:2376 DOCKER_TLS_VERIFY=1
+                        docker service rollback ${service_name}
+                     '''
+                }
               }
               throw err
             }