From f727478e53144dfe1d592419ef3fe7a5394d060c Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Tue, 16 Jun 2026 13:18:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(jenkins):=20SNAPSHOT=20=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=80=92=E5=A2=9E=20alpha=20=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=EF=BC=88=E6=9F=A5=E8=AF=A2=20registry=20?= =?UTF-8?q?=E6=9C=80=E6=96=B0=20alpha=20=E5=90=8E=20+1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f12537c..3c3102e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -91,8 +91,23 @@ pipeline { def newVer if (params.SNAPSHOT) { - // SNAPSHOT:仅追加 -alpha.1 后缀,不修改 package.json,不 commit - newVer = baseVer + '-alpha.1' + // SNAPSHOT:查询 registry 上最新的 alpha 版本,自动递增 + def alphaNum = 1 + try { + def remoteVer = bat( + script: "@npm view ${pkg} dist-tags.alpha --registry %NEXUS_REGISTRY% 2>nul", + returnStdout: true + ).trim() + if (remoteVer && remoteVer.matches(/.*-alpha\.\d+$/)) { + def matcher = (remoteVer =~ /-alpha\.(\d+)$/) + if (matcher.find()) { + alphaNum = matcher.group(1).toInteger() + 1 + } + } + } catch (Exception e) { + echo "Could not query remote version for ${pkg}, using alpha.1" + } + newVer = baseVer + "-alpha.${alphaNum}" echo "SNAPSHOT publish: ${pkg} → ${newVer} (tag: alpha)" // 临时写入 package.json 供 npm publish 读取(不 commit) bat """node -e "var fs=require('fs'),p='${dir}/package.json',j=JSON.parse(fs.readFileSync(p,'utf8'));j.version='${newVer}';fs.writeFileSync(p,JSON.stringify(j,null,2)+'\\n','utf8');" """