From 239de5fd612601aab18fcb9fb954c0402ae801cc Mon Sep 17 00:00:00 2001 From: cat_shark <1716967236@qq.com> Date: Sun, 27 Jul 2025 19:38:00 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=8A=A0=E5=85=A5=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 54b0df9..a54e357 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -58,21 +58,25 @@ pipeline { } } - stage('Run Docker Container') { + stage('Check Docker Status') { agent any steps { - sh ''' - docker rm -f $CONTAINER_NAME || true - docker run -d --name $CONTAINER_NAME \\ - -p $HOST_PORT:$CONTAINER_PORT \\ - --health-cmd="curl -f http://localhost:$CONTAINER_PORT || exit 1" \\ - --health-interval=10s \\ - --health-timeout=5s \\ - --health-retries=3 \\ - $IMAGE_NAME - ''' + script { + timeout(time: 60, unit: 'SECONDS') { + waitUntil { + def status = sh( + script: "docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME || echo 'no-healthcheck'", + returnStdout: true + ).trim() + echo "Current container status: ${status}" + return (status == 'healthy') + } } } + } +} + + } }