Parcourir la source

Обновить 'Jenkinsfile'

Vladimir Tomishinets il y a 7 ans
Parent
commit
7961f43ec3
1 fichiers modifiés avec 23 ajouts et 0 suppressions
  1. 23 0
      Jenkinsfile

+ 23 - 0
Jenkinsfile

@@ -118,6 +118,29 @@ pipeline {
            '''
            '''
       }
       }
     }
     }
+    stage("Tagging") {
+        steps {
+          echo "Tagging ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER} to ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:latest"
+          sh '''docker tag ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER} \
+                ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:latest
+                docker push ${DOCKER_REGISTRY}/iru/${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 ${BUILD_NUMBER} > tags/${DOCKER_IMAGE}.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 {
   post {
     always {
     always {