fix:加入健康检查

This commit is contained in:
2025-07-27 19:38:00 +08:00
parent 13ade2e001
commit 239de5fd61
Vendored
+15 -11
View File
@@ -58,21 +58,25 @@ pipeline {
} }
} }
stage('Run Docker Container') { stage('Check Docker Status') {
agent any agent any
steps { steps {
sh ''' script {
docker rm -f $CONTAINER_NAME || true timeout(time: 60, unit: 'SECONDS') {
docker run -d --name $CONTAINER_NAME \\ waitUntil {
-p $HOST_PORT:$CONTAINER_PORT \\ def status = sh(
--health-cmd="curl -f http://localhost:$CONTAINER_PORT || exit 1" \\ script: "docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME || echo 'no-healthcheck'",
--health-interval=10s \\ returnStdout: true
--health-timeout=5s \\ ).trim()
--health-retries=3 \\ echo "Current container status: ${status}"
$IMAGE_NAME return (status == 'healthy')
''' }
} }
} }
}
}
} }
} }