Browse Source

Избавление от NODE_IP

Tomishinets Vladimir 3 years ago
parent
commit
2105f81796
1 changed files with 4 additions and 3 deletions
  1. 4 3
      Jenkinsfile.renewal

+ 4 - 3
Jenkinsfile.renewal

@@ -28,9 +28,10 @@ pipeline {
         script {
           def NODE = sh (script: "DOCKER_HOST=tcp://${CLUSTER_NAME}:2376 DOCKER_TLS_VERIFY=1 docker service ps \${SERVICE_NAME} --format '{{.Node}}' --filter desired-state=Running" , returnStdout: true).trim()
           sh "if [ -z ${NODE} ]; then echo '${SERVICE_NAME} does not running'; exit 1; fi"
-          def NODE_IP = sh (script: "DOCKER_HOST=tcp://${CLUSTER_NAME}:2376 DOCKER_TLS_VERIFY=1 docker node inspect ${NODE} -f '{{.Status.Addr}}'" , returnStdout: true).trim()
-          def container_id = sh (script: "DOCKER_HOST=tcp://${NODE_IP}:2376 DOCKER_TLS_VERIFY=1 docker ps -q -f label=com.docker.swarm.service.name=\${SERVICE_NAME}" , returnStdout: true).trim()
-          sh "DOCKER_HOST=tcp://${NODE_IP}:2376 DOCKER_TLS_VERIFY=1 docker exec -i ${container_id} /tmp/renewal.sh"
+          NODE_NAME_LOCAL = NODE.replace(".ru", ".lan")
+          // def NODE_IP = sh (script: "DOCKER_HOST=tcp://${CLUSTER_NAME}:2376 DOCKER_TLS_VERIFY=1 docker node inspect ${NODE} -f '{{.Status.Addr}}'" , returnStdout: true).trim()
+          def container_id = sh (script: "DOCKER_HOST=tcp://${NODE_NAME_LOCAL}:2376 DOCKER_TLS_VERIFY=1 docker ps -q -f label=com.docker.swarm.service.name=\${SERVICE_NAME}" , returnStdout: true).trim()
+          sh "DOCKER_HOST=tcp://${NODE_NAME_LOCAL}:2376 DOCKER_TLS_VERIFY=1 docker exec -i ${container_id} /tmp/renewal.sh"
         }
       }
     }