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>
这个提交包含在:
父节点
50eb60b895
当前提交
07d6307b5d
10
Jenkinsfile
vendored
10
Jenkinsfile
vendored
@ -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
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户