From 24b7abb361b84611377d95956bbb2ec36f08596e Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Sat, 23 May 2026 01:57:14 +0800 Subject: [PATCH] fix(ci): use Groovy readProperties for version, add git pull before push MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace PowerShell-based version reading with Groovy's readProperties and readFile/writeFile to avoid encoding issues causing "1.0.3→1.0.3" - Add git pull --rebase before push to handle non-fast-forward rejections Co-Authored-By: Claude Opus 4.7 --- Jenkinsfile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0fd41d2..fe287f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,10 +50,9 @@ pipeline { stage('Resolve Versions') { steps { script { - def currentVer = bat( - script: "@powershell -Command \"(Get-Content gradle.properties | Select-String '^PUBLISH_VERSION=').Line.Split('=')[1]\"", - returnStdout: true - ).replaceAll("\\r","").replaceAll("\\n","").trim() + // Read version using Groovy to avoid PowerShell encoding issues + def props = readProperties file: 'gradle.properties' + def currentVer = props['PUBLISH_VERSION'] ?: '0.1.0' echo "Current PUBLISH_VERSION: ${currentVer}" def parts = currentVer.tokenize('.') @@ -77,7 +76,10 @@ pipeline { echo "Auto-bumped PUBLISH_VERSION: ${currentVer} → ${newVer}" env.NEW_VERSION = newVer - bat "powershell -Command \"(Get-Content gradle.properties) -replace '^PUBLISH_VERSION=.*', 'PUBLISH_VERSION=${newVer}' | Set-Content gradle.properties\"" + // Write back using Groovy to avoid PowerShell encoding issues + def content = readFile('gradle.properties') + content = content.replaceAll(/(?m)^PUBLISH_VERSION=.*/, "PUBLISH_VERSION=${newVer}") + writeFile file: 'gradle.properties', text: content def modules = env.PUBLISH_MODULES.split(',').toList() def versionMap = [:] @@ -122,6 +124,7 @@ pipeline { git config user.name "Jenkins CI" git add gradle.properties git diff --cached --quiet || git commit -m "ci: bump PUBLISH_VERSION to ${env.NEW_VERSION}" + git pull --rebase origin main git push origin main """ }