Владимир Томишинец 5 years ago
parent
commit
2d05f61a96
1 changed files with 28 additions and 12 deletions
  1. 28 12
      Jenkinsfile-prod

+ 28 - 12
Jenkinsfile-prod

@@ -1,11 +1,12 @@
 def SERIAL
 def PROD = [ dir: 'stack-deploy', url: 'ssh://git@git.sdsys.ru:8022/iru/stack-deploy.git', host: 'tcp://iru-swarm.infoclinica.lan:2376 DOCKER_TLS_VERIFY=1', registry: 'registry.infoclinica.ru:5000' ]
-def VOLGA = [ dir: 'stack-deploy-volga', url: 'ssh://git@git.sdsys.ru:8022/iru/stack-deploy-volga.git', host: 'tcp://iru-volga.infoclinica.lan:2376 DOCKER_TLS_VERIFY=1', registry: 'risz-registry.volganet.ru:5000' ]
-def TULA = [ dir: 'stack-deploy-tula', url: 'ssh://git@git.sdsys.ru:8022/iru/stack-deploy-tula.git', host: 'tcp://iru-tula.infoclinica.lan:2376 DOCKER_TLS_VERIFY=1', registry: 'registry.doctor71.ru:5000' ]
+def VOLGA = [ dir: 'stack-deploy-volga', url: 'ssh://git@git.sdsys.ru:8022/iru/stack-deploy-volga.git', host: 'tcp://iru-volga.infoclinica.lan:2376 DOCKER_TLS_VERIFY=1', registry: 'risz-registry.volganet.ru:5000', service: 'info_node-api' ]
+def TULA = [ dir: 'stack-deploy-tula', url: 'ssh://git@git.sdsys.ru:8022/iru/stack-deploy-tula.git', host: 'tcp://iru-tula.infoclinica.lan:2376 DOCKER_TLS_VERIFY=1', registry: 'registry.doctor71.ru:5000', service: 'info_node-api' ]
 def GIT_DIR = ''
 def GIT_URL = ''
 def DHOST = ''
 def REGISTRY = ''
+def SERVICE = ''
 def GIT_DIR_PROD = ''
 def GIT_URL_PROD = ''
 pipeline {
@@ -51,12 +52,14 @@ pipeline {
               GIT_URL = VOLGA['url']
               DHOST = VOLGA['host']
               REGISTRY = VOLGA['registry']
+              SERVICE = VOLGA['service']
               break
             case 'TULA':
               GIT_DIR = TULA['dir']
               GIT_URL = TULA['url']
               DHOST = TULA['host']
               REGISTRY = TULA['registry']
+              SERVICE = TULA['service']
               break
           }
         }
@@ -101,17 +104,30 @@ pipeline {
     stage("Updating service"){
       steps{
         script {
-          for (String item : service_update.split()) {
-            echo "Updating ${item}"
-            try{
-              sh "DOCKER_HOST=${DHOST} docker service update ${item} --image ${REGISTRY}/${DOCKER_IMAGE}:${NEWTAG}"
-            }
-            catch(err){
-              echo "Recovering service $item"
-              sh "DOCKER_HOST=${DHOST} docker service rollback ${item}"
-              throw err
-            }
+          if (CLUSTER == 'PROD') {
+            for (String item : service_update.split()) {
+              echo "Updating ${item}"
+              try{
+                sh "DOCKER_HOST=${DHOST} docker service update ${item} --image ${REGISTRY}/${DOCKER_IMAGE}:${NEWTAG}"
+              }
+              catch(err){
+                echo "Recovering service $item"
+                sh "DOCKER_HOST=${DHOST} docker service rollback ${item}"
+                throw err
+              }
+            }  
+          } else {
+              try{
+                echo "Updating ${SERVICE}"
+                sh "DOCKER_HOST=${DHOST} docker service update ${SERVICE} --image ${REGISTRY}/${DOCKER_IMAGE}:${NEWTAG}"
+              }
+              catch(err){
+                echo "Recovering service ${SERVICE}"
+                sh "DOCKER_HOST=${DHOST} docker service rollback ${SERVICE}"
+                throw err
+              }
           }
+          
         }
       }
     }