Selaa lähdekoodia

Включил обновление сервисов и тегирование

Tomishinets Vladimir 3 vuotta sitten
vanhempi
commit
6d08c69995
1 muutettua tiedostoa jossa 35 lisäystä ja 35 poistoa
  1. 35 35
      Jenkinsfile-dev

+ 35 - 35
Jenkinsfile-dev

@@ -83,41 +83,41 @@ pipeline {
         sh "docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${NEWTAG}"
       }
     }
-    // stage("Update") {
-    //   steps {
-    //     script {
-    //       try{
-    //          sh "DOCKER_HOST=${DHOST} docker service update ${SERVICE_NAME} --image ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${NEWTAG}"
-    //       }
-    //       catch(err){
-    //          echo "Recovering service $item"
-    //          sh "DOCKER_HOST=${DHOST} docker service rollback ${SERVICE_NAME}"
-    //          throw err
-    //       }
-    //     }
-    //   }
-    // }
-    // stage("Tagging"){
-    //   steps{
-    //     echo "Setting latest tag"
-    //     sh """docker tag ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${NEWTAG} ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:latest
-    //           docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:latest"""
-    //     echo "Updating tag info in ${SWARM_GIT_NAME} repository"
-    //     withCredentials([sshUserPrivateKey(credentialsId: 'provision', keyFileVariable: 'GIT_SSH_KEY', passphraseVariable: '', usernameVariable: 'GIT_SSH_USERNAME')]) {
-    //       sh """GIT_SSH_COMMAND='ssh -i ${GIT_SSH_KEY} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
-    //               git clone ${SWARM_GIT_URL}
-    //             cd ${SWARM_GIT_NAME}
-    //             echo -n ${NEWTAG} > tags/${DOCKER_IMAGE}.dev-version
-    //             git add -A
-    //             git config --global user.email "${JENKINS_MAIL}"
-    //             git config --global user.name "Jenkins"
-    //             git commit -m 'Version update'
-    //             GIT_SSH_COMMAND='ssh -i ${GIT_SSH_KEY} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
-    //               git push origin master
-    //          """
-    //     }
-    //   }
-    // }
+    stage("Update") {
+      steps {
+        script {
+          try{
+             sh "DOCKER_HOST=${DHOST} docker service update ${SERVICE_NAME} --image ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${NEWTAG}"
+          }
+          catch(err){
+             echo "Recovering service $item"
+             sh "DOCKER_HOST=${DHOST} docker service rollback ${SERVICE_NAME}"
+             throw err
+          }
+        }
+      }
+    }
+    stage("Tagging"){
+      steps{
+        echo "Setting latest tag"
+        sh """docker tag ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${NEWTAG} ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:latest
+              docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:latest"""
+        echo "Updating tag info in ${SWARM_GIT_NAME} repository"
+        withCredentials([sshUserPrivateKey(credentialsId: 'provision', keyFileVariable: 'GIT_SSH_KEY', passphraseVariable: '', usernameVariable: 'GIT_SSH_USERNAME')]) {
+          sh """GIT_SSH_COMMAND='ssh -i ${GIT_SSH_KEY} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
+                  git clone ${SWARM_GIT_URL}
+                cd ${SWARM_GIT_NAME}
+                echo -n ${NEWTAG} > tags/${DOCKER_IMAGE}.dev-version
+                git add -A
+                git config --global user.email "${JENKINS_MAIL}"
+                git config --global user.name "Jenkins"
+                git commit -m 'Version update'
+                GIT_SSH_COMMAND='ssh -i ${GIT_SSH_KEY} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
+                  git push origin master
+             """
+        }
+      }
+    }
   }
   post {
     always {