From 7606a715253f8bb5e197469ffab6402679df4955 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Sat, 23 May 2026 01:34:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ci):=20=E7=A7=BB=E9=99=A4=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=89=88=E6=9C=AC=E5=8F=B7=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E4=BB=85=E4=BF=9D=E7=95=99=E8=87=AA=E5=8A=A8=E5=8D=87?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 75 ++++++++++++++++------------------------------------- 1 file changed, 22 insertions(+), 53 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e982842..f161e8d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,17 +5,6 @@ pipeline { // ── 版本升级策略 ───────────────────────────────────────────────────── choice(name: 'VERSION_BUMP', choices: ['patch', 'minor', 'major'], description: '版本升级策略: major(1.0.0→2.0.0), minor(1.0.0→1.1.0), patch(1.0.0→1.0.1)') - booleanParam(name: 'CUSTOM_VERSION', defaultValue: false, - description: '勾选后使用下方自定义版本号(忽略VERSION_BUMP)') - - // ── 模块自定义版本号(仅CUSTOM_VERSION=true时生效)─────────────────── - string(name: 'CORE_VERSION', defaultValue: '', description: 'XuqmCoreSDK 自定义版本号(仅CUSTOM_VERSION=true时生效)') - string(name: 'IM_VERSION', defaultValue: '', description: 'XuqmImSDK 自定义版本号') - string(name: 'PUSH_VERSION', defaultValue: '', description: 'XuqmPushSDK 自定义版本号') - string(name: 'UPDATE_VERSION', defaultValue: '', description: 'XuqmUpdateSDK 自定义版本号') - string(name: 'LICENSE_VERSION', defaultValue: '', description: 'XuqmLicenseSDK 自定义版本号') - string(name: 'FILE_VERSION', defaultValue: '', description: 'XuqmFileSDK 自定义版本号') - string(name: 'WEBVIEW_VERSION', defaultValue: '', description: 'XuqmWebViewSDK 自定义版本号') // ── 模块选择(勾选即发布)───────────────────────────────────────── booleanParam(name: 'MOD_CORE', defaultValue: true, description: '发布 XuqmCoreSDK') @@ -92,15 +81,6 @@ pipeline { script { def moduleMap = new groovy.json.JsonSlurper().parseText(env.MODULE_MAP) def modules = env.SELECTED_MODULES.split(',') - def customVersions = [ - 'core': params.CORE_VERSION?.trim(), - 'im': params.IM_VERSION?.trim(), - 'push': params.PUSH_VERSION?.trim(), - 'update': params.UPDATE_VERSION?.trim(), - 'license': params.LICENSE_VERSION?.trim(), - 'file': params.FILE_VERSION?.trim(), - 'webview': params.WEBVIEW_VERSION?.trim(), - ] for (mod in modules) { def podspecFile = "${moduleMap[mod].podspec}.podspec" @@ -109,40 +89,29 @@ pipeline { returnStdout: true ).trim() - def newVer = '' - if (params.CUSTOM_VERSION && customVersions[mod]) { - // 使用自定义版本号 - newVer = customVersions[mod] - } else if (!params.CUSTOM_VERSION) { - // 根据 VERSION_BUMP 策略自动升级版本号 - def parts = currentVer.tokenize('.') - while (parts.size() < 3) { parts.add('0') } - switch (params.VERSION_BUMP) { - case 'major': - parts[0] = (parts[0].toInteger() + 1).toString() - parts[1] = '0' - parts[2] = '0' - break - case 'minor': - parts[1] = (parts[1].toInteger() + 1).toString() - parts[2] = '0' - break - case 'patch': - default: - parts[2] = (parts[2].toInteger() + 1).toString() - break - } - newVer = parts.join('.') + // 根据 VERSION_BUMP 策略自动升级版本号 + def parts = currentVer.tokenize('.') + while (parts.size() < 3) { parts.add('0') } + switch (params.VERSION_BUMP) { + case 'major': + parts[0] = (parts[0].toInteger() + 1).toString() + parts[1] = '0' + parts[2] = '0' + break + case 'minor': + parts[1] = (parts[1].toInteger() + 1).toString() + parts[2] = '0' + break + case 'patch': + default: + parts[2] = (parts[2].toInteger() + 1).toString() + break } + def newVer = parts.join('.') - if (newVer && newVer != currentVer) { - echo "Bumping ${moduleMap[mod].podspec}: ${currentVer} → ${newVer}" - sh "sed -i '' 's/s.version.*= .*/s.version = \"${newVer}\"/' ${podspecFile}" - env["VERSION_${mod}"] = newVer - } else { - echo "Keeping ${moduleMap[mod].podspec} at ${currentVer}" - env["VERSION_${mod}"] = currentVer - } + echo "Bumping ${moduleMap[mod].podspec}: ${currentVer} → ${newVer}" + sh "sed -i '' 's/s.version.*= .*/s.version = \"${newVer}\"/' ${podspecFile}" + env["VERSION_${mod}"] = newVer } } } @@ -154,7 +123,7 @@ pipeline { def modules = env.SELECTED_MODULES.split(',') def moduleMap = new groovy.json.JsonSlurper().parseText(env.MODULE_MAP) echo "Git Commit : ${env.GIT_COMMIT_SHORT}" - echo "Bump Strategy: ${params.CUSTOM_VERSION ? 'Custom' : params.VERSION_BUMP}" + echo "Bump Strategy: ${params.VERSION_BUMP}" echo "Modules (${modules.size()}):" for (mod in modules) { def ver = env["VERSION_${mod}"]