Browse Source

Обновить 'Jenkinsfile'

Vladimir Tomishinets 6 years ago
parent
commit
191da6c375
1 changed files with 23 additions and 61 deletions
  1. 23 61
      Jenkinsfile

+ 23 - 61
Jenkinsfile

@@ -95,75 +95,37 @@ pipeline {
           echo "${NODE}"
           sh """container_id_client=\$(docker run -e mode=client -e server=${NODE} --privileged -d --rm  ${DOCKER_IMAGE}:${SERIAL})
                 docker exec -t \${container_id_client} ping -c 3 -q 10.10.20.1
-                if [ \$? != 0 ]; then exit 1; else echo 'DNS is working!!!'; fi
+                if [ \$? != 0 ]; then exit 1; else echo 'OVPN_RSA is working!!!'; fi
              """
              
         }
       }
     }
-
-/*    stage("Prod-like") {
+    stage ("Tagging") {
       steps {
-        echo "Check Prod-like cluster status"
-        sh '''ping -c 2 ${CLUSTER_NAME}
-              if [ $? -eq 0 ]; then
-                export DOCKER_CERT_PATH=/run/secrets/swarm
-                export DOCKER_HOST=tcp://${CLUSTER_NAME}:2376 DOCKER_TLS_VERIFY=1
-                docker node ls --format "{{.Hostname}} {{.TLSStatus}}" | while read host status
-                do
-                  if [ $status != Ready ]; then echo "Cluster ${CLUSTER_NAME} state is inconsistent"; exit 1
-                  else echo "HOST: $host STATUS: $status"
-                  fi
-                done
-              else echo "Host not Found"; exit 1
-              fi
-           '''
-        echo "Run containers in Prod-like"
-        sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
-              export DOCKER_HOST=tcp://${CLUSTER_NAME}:2376 DOCKER_TLS_VERIFY=1
-              export DOCKER_HOST=tcp://$(docker info -f '{{.Name}}'):2376 DOCKER_TLS_VERIFY=1
-              if [ -z $(docker service ps -q ${DOCKER_IMAGE}) ];then
-                docker service create --replicas 1 \
-                --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock \
-                --name ${SERVICE_NAME} ${DOCKER_REGISTRY}/${SERVICE_IMAGE}:2 -p 1194:1194 \
-                --privileged --security-opt seccomp=unconfined \
-                --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-                -e "mode=server" ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER}
-              else
-                docker service update \
-                --args "-p 1194:1194 --privileged --security-opt seccomp=unconfined \
-                --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-                -e "mode=server" ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER}" \
-                ${SERVICE_NAME}
-                if [ $? != 0 ]; then docker service rollback ${SERVICE_NAME}; fi
-              fi
-           '''
+        script {
+          ENAMES.each { item ->
+             echo "Setting latest tag for $item"
+             sh """docker tag ${DOCKER_IMAGE}:${SERIAL} ${REGISTRIES.get((item))}/${DOCKER_IMAGE}:latest
+                   docker push ${REGISTRIES.get((item))}/${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 """cd ${SWARM_GIT_NAME}
+                echo -n ${SERIAL} > 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
+             """
+        }
       }
     }
-    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 {
     always {
       echo "CleaningUp work directory"