fix(ci): 修复 bat 脚本错误处理,Docker 失败时立即退出

原 || 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 <noreply@anthropic.com>
这个提交包含在:
XuqmGroup 2026-06-11 15:20:16 +08:00
父节点 50eb60b895
当前提交 07d6307b5d

10
Jenkinsfile vendored
查看文件

@ -70,10 +70,14 @@ pipeline {
def gitCommit = env.GIT_COMMIT ?: 'unknown' def gitCommit = env.GIT_COMMIT ?: 'unknown'
bat """ bat """
docker login ${env.ACR_REGISTRY} -u ${env.ACR_USERNAME} -p %ACR_PASS% 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 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 build --platform=linux/amd64 -f ${env.DOCKERFILE} ${env.BUILD_ARGS} --build-arg GIT_COMMIT=${gitCommit} ${cacheArgs} -t ${fullImage} .
docker push ${fullImage} || exit /b %ERRORLEVEL% if %errorlevel% neq 0 exit /b 1
docker rmi ${fullImage} || exit 0 docker push ${fullImage}
if %errorlevel% neq 0 exit /b 1
docker rmi ${fullImage}
exit /b 0
""" """
} }
} }