fix:加入健康检查

This commit is contained in:
2025-07-27 20:33:47 +08:00
parent c653d6a7ef
commit ec427dd19a
Vendored
+14 -10
View File
@@ -52,6 +52,7 @@ pipeline {
sh '''
docker rm -f $CONTAINER_NAME || true
docker run -d --name $CONTAINER_NAME \\
--network mysql_default \\
-p $HOST_PORT:$CONTAINER_PORT \\
--health-cmd="curl -f http://localhost:80 || exit 1" \\
--health-interval=5s \\
@@ -65,21 +66,24 @@ pipeline {
agent any
steps {
script {
def lastStatus = ''
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')
script: "docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME || echo 'no-healthcheck'",
returnStdout: true
).trim()
if (status != lastStatus) {
echo "Container health: ${status}"
lastStatus = status
}
return (status == 'healthy')
}
}
}
}
}
}
}
}
}