fix: 从 versionedImage 提取版本号传给 docker build,绕过 env.SERVICE_VERSION 在 bat GString 中求值为空的问题
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
父节点
8fa9856aa0
当前提交
a81e7ecfab
4
Jenkinsfile
vendored
4
Jenkinsfile
vendored
@ -81,12 +81,14 @@ pipeline {
|
||||
? '--no-cache'
|
||||
: "--build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ${latestImage}"
|
||||
def gitCommit = env.GIT_COMMIT ?: 'unknown'
|
||||
// 从 versionedImage 提取版本号(env.SERVICE_VERSION 在 bat GString 中求值为空,本地变量可靠)
|
||||
def svcVersion = versionedImage.split(':').last()
|
||||
bat """
|
||||
chcp 65001 >nul
|
||||
docker login ${env.ACR_REGISTRY} -u ${env.ACR_USERNAME} -p %ACR_PASS%
|
||||
if %errorlevel% neq 0 exit /b 1
|
||||
docker pull --platform=linux/amd64 ${latestImage} || echo Pull failed, will build fresh
|
||||
docker build --platform=linux/amd64 -f ${env.DOCKERFILE} ${env.BUILD_ARGS} --build-arg GIT_COMMIT=${gitCommit} --build-arg SERVICE_VERSION=%SERVICE_VERSION% ${cacheArgs} -t ${versionedImage} -t ${latestImage} .
|
||||
docker build --platform=linux/amd64 -f ${env.DOCKERFILE} ${env.BUILD_ARGS} --build-arg GIT_COMMIT=${gitCommit} --build-arg SERVICE_VERSION=${svcVersion} ${cacheArgs} -t ${versionedImage} -t ${latestImage} .
|
||||
if %errorlevel% neq 0 exit /b 1
|
||||
docker push ${versionedImage}
|
||||
if %errorlevel% neq 0 exit /b 1
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户