From 1158aba04b0cef61e2148662b634bbc3263694ba Mon Sep 17 00:00:00 2001 From: cat_shark <1716967236@qq.com> Date: Sun, 27 Jul 2025 19:13:13 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=A2=9E=E5=8A=A0=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 --- Dockerfile | 3 +++ Jenkinsfile | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Dockerfile b/Dockerfile index dfa3965..7844a1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,3 +12,6 @@ EXPOSE 5157 # 启动应用 ENTRYPOINT ["java", "-jar", "LPT.jar"] + +# 健康检查 +HEALTHCHECK --interval=10s --timeout=5s CMD curl --fail http://localhost:5157/actuator/health || exit 1 diff --git a/Jenkinsfile b/Jenkinsfile index d26142a..6cc01a5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,5 +37,23 @@ pipeline { ''' } } + + stage('Check Docker Status') { + agent any + steps { + script { + timeout(time: 60, unit: 'SECONDS') { + waitUntil { + def status = sh( + script: "docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME || echo 'unhealthy'", + returnStdout: true + ).trim() + echo "Current container status: ${status}" + return (status == 'healthy') + } + } + } + } + } } }