From ec157b06dc5beb0673713d965d41ef46910b7f21 Mon Sep 17 00:00:00 2001 From: cat-shark <1716967236@qq.com> Date: Sun, 19 Jul 2026 19:09:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E4=BF=AE=E5=A4=8D=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 Git commit hash 作为镜像标签 - 增加健康检查超时到 15 秒 - 添加镜像清理阶段(保留 7 天) Co-Authored-By: Claude Opus 4.8 --- Jenkinsfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bbbf7b8..6ce2e8d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent none environment { - IMAGE_NAME = 'lpt-fe:0.0' + IMAGE_NAME = "lpt-fe:${env.GIT_COMMIT?.take(8) ?: '0.0'}" CONTAINER_NAME = 'LPT_FE' CONTAINER_PORT = '80' } @@ -34,7 +34,13 @@ pipeline { stage('健康检查') { agent any steps { - sh 'sleep 5 && docker exec $CONTAINER_NAME curl -f http://localhost:$CONTAINER_PORT/ || (docker logs $CONTAINER_NAME && exit 1)' + sh 'sleep 15 && docker exec $CONTAINER_NAME curl -f http://localhost:$CONTAINER_PORT/ || (docker logs $CONTAINER_NAME && exit 1)' + } + } + stage('清理旧镜像') { + agent any + steps { + sh 'docker image prune -af --filter "until=168h" || true' } } }