fix(ci): use Groovy readProperties for version, add git pull before push
- 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 <noreply@anthropic.com>
这个提交包含在:
父节点
c60bc15a93
当前提交
24b7abb361
13
Jenkinsfile
vendored
13
Jenkinsfile
vendored
@ -50,10 +50,9 @@ pipeline {
|
|||||||
stage('Resolve Versions') {
|
stage('Resolve Versions') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def currentVer = bat(
|
// Read version using Groovy to avoid PowerShell encoding issues
|
||||||
script: "@powershell -Command \"(Get-Content gradle.properties | Select-String '^PUBLISH_VERSION=').Line.Split('=')[1]\"",
|
def props = readProperties file: 'gradle.properties'
|
||||||
returnStdout: true
|
def currentVer = props['PUBLISH_VERSION'] ?: '0.1.0'
|
||||||
).replaceAll("\\r","").replaceAll("\\n","").trim()
|
|
||||||
echo "Current PUBLISH_VERSION: ${currentVer}"
|
echo "Current PUBLISH_VERSION: ${currentVer}"
|
||||||
|
|
||||||
def parts = currentVer.tokenize('.')
|
def parts = currentVer.tokenize('.')
|
||||||
@ -77,7 +76,10 @@ pipeline {
|
|||||||
echo "Auto-bumped PUBLISH_VERSION: ${currentVer} → ${newVer}"
|
echo "Auto-bumped PUBLISH_VERSION: ${currentVer} → ${newVer}"
|
||||||
env.NEW_VERSION = 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 modules = env.PUBLISH_MODULES.split(',').toList()
|
||||||
def versionMap = [:]
|
def versionMap = [:]
|
||||||
@ -122,6 +124,7 @@ pipeline {
|
|||||||
git config user.name "Jenkins CI"
|
git config user.name "Jenkins CI"
|
||||||
git add gradle.properties
|
git add gradle.properties
|
||||||
git diff --cached --quiet || git commit -m "ci: bump PUBLISH_VERSION to ${env.NEW_VERSION}"
|
git diff --cached --quiet || git commit -m "ci: bump PUBLISH_VERSION to ${env.NEW_VERSION}"
|
||||||
|
git pull --rebase origin main
|
||||||
git push origin main
|
git push origin main
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户