From 07d6307b5d66745aa6fecedcd0a732e700e50dd3 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Thu, 11 Jun 2026 15:20:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E4=BF=AE=E5=A4=8D=20bat=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=EF=BC=8CDocker=20?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E7=AB=8B=E5=8D=B3=E9=80=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原 || exit /b %ERRORLEVEL% 在 Windows bat 中无法可靠捕获 Docker API 错误(Docker Desktop 宕机时返回 500 但 %ERRORLEVEL% 可能仍为 0), 导致构建失败时管道仍标记为 SUCCESS。改为 if %errorlevel% neq 0 exit /b 1。 Co-Authored-By: Claude Sonnet 4.6 --- Jenkinsfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bc84972..7a70eb0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -70,10 +70,14 @@ pipeline { def gitCommit = env.GIT_COMMIT ?: 'unknown' bat """ docker login ${env.ACR_REGISTRY} -u ${env.ACR_USERNAME} -p %ACR_PASS% + if %errorlevel% neq 0 exit /b 1 docker pull --platform=linux/amd64 ${fullImage} || echo Pull failed, will build fresh - docker build --platform=linux/amd64 -f ${env.DOCKERFILE} ${env.BUILD_ARGS} --build-arg GIT_COMMIT=${gitCommit} ${cacheArgs} -t ${fullImage} . || exit /b %ERRORLEVEL% - docker push ${fullImage} || exit /b %ERRORLEVEL% - docker rmi ${fullImage} || exit 0 + docker build --platform=linux/amd64 -f ${env.DOCKERFILE} ${env.BUILD_ARGS} --build-arg GIT_COMMIT=${gitCommit} ${cacheArgs} -t ${fullImage} . + if %errorlevel% neq 0 exit /b 1 + docker push ${fullImage} + if %errorlevel% neq 0 exit /b 1 + docker rmi ${fullImage} + exit /b 0 """ } }