From a81e7ecfaba1a854e3283aa7f983c60458172067 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Wed, 24 Jun 2026 17:26:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=8E=20versionedImage=20=E6=8F=90?= =?UTF-8?q?=E5=8F=96=E7=89=88=E6=9C=AC=E5=8F=B7=E4=BC=A0=E7=BB=99=20docker?= =?UTF-8?q?=20build=EF=BC=8C=E7=BB=95=E8=BF=87=20env.SERVICE=5FVERSION=20?= =?UTF-8?q?=E5=9C=A8=20bat=20GString=20=E4=B8=AD=E6=B1=82=E5=80=BC?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5f6f637..a3379c8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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