fix(jenkins): SNAPSHOT 模式自动递增 alpha 版本号(查询 registry 最新 alpha 后 +1)
这个提交包含在:
父节点
e5130c4627
当前提交
f727478e53
19
Jenkinsfile
vendored
19
Jenkinsfile
vendored
@ -91,8 +91,23 @@ pipeline {
|
|||||||
|
|
||||||
def newVer
|
def newVer
|
||||||
if (params.SNAPSHOT) {
|
if (params.SNAPSHOT) {
|
||||||
// SNAPSHOT:仅追加 -alpha.1 后缀,不修改 package.json,不 commit
|
// SNAPSHOT:查询 registry 上最新的 alpha 版本,自动递增
|
||||||
newVer = baseVer + '-alpha.1'
|
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)"
|
echo "SNAPSHOT publish: ${pkg} → ${newVer} (tag: alpha)"
|
||||||
// 临时写入 package.json 供 npm publish 读取(不 commit)
|
// 临时写入 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');" """
|
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');" """
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户