From 1151724a2a67fdcaeb29d223bbdaefac0ed44f4f Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Wed, 24 Jun 2026 17:01:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20readCurrentVersion=20=E4=BC=98=E5=85=88?= =?UTF-8?q?=E8=AF=BB=20/app/SERVICE=5FVERSION=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20currentVersion=20=E6=B0=B8=E8=BF=9C=E8=BF=94=E5=9B=9E=20"1.0?= =?UTF-8?q?.0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dockerfile 中 COPY VERSION /app/VERSION 拷贝的是 repo 根目录的静态文件(始终是 "1.0.0"), 实际构建版本通过 build-arg SERVICE_VERSION 写入 /app/SERVICE_VERSION。 改为优先读 /app/SERVICE_VERSION,使 check-update 返回正确的 currentVersion。 Co-Authored-By: Claude Sonnet 4.6 --- .../com/xuqm/tenant/service/SystemUpdateService.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tenant-service/src/main/java/com/xuqm/tenant/service/SystemUpdateService.java b/tenant-service/src/main/java/com/xuqm/tenant/service/SystemUpdateService.java index a7929a7..6c3aa9d 100644 --- a/tenant-service/src/main/java/com/xuqm/tenant/service/SystemUpdateService.java +++ b/tenant-service/src/main/java/com/xuqm/tenant/service/SystemUpdateService.java @@ -152,9 +152,17 @@ public class SystemUpdateService { } } - /** 读取镜像内打包的 VERSION 文件,返回当前版本号,文件不存在时返回 "unknown"。 */ + /** 读取镜像内打包的版本号,返回当前版本号,文件不存在时返回 "unknown"。 */ public String readCurrentVersion() { - // 优先读镜像内 /app/VERSION + // Jenkins 构建时写入的实际版本号(SERVICE_VERSION build-arg) + Path serviceVersion = Paths.get("/app/SERVICE_VERSION"); + try { + if (Files.exists(serviceVersion)) { + String v = Files.readString(serviceVersion).trim(); + if (!v.isEmpty()) return v; + } + } catch (IOException ignored) {} + // 兼容旧镜像:/app/VERSION(repo 根目录静态文件,可能不准确) Path containerVersion = Paths.get("/app/VERSION"); try { if (Files.exists(containerVersion)) {