fix(ci): explicit ASCII encoding for version read, git checkout main
- Force ASCII output encoding in PowerShell to avoid hidden chars - Add git checkout main before commit to avoid detached HEAD - Simplify version reading command Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
这个提交包含在:
父节点
24b7abb361
当前提交
883a623505
38
Jenkinsfile
vendored
38
Jenkinsfile
vendored
@ -50,36 +50,31 @@ pipeline {
|
||||
stage('Resolve Versions') {
|
||||
steps {
|
||||
script {
|
||||
// Read version using Groovy to avoid PowerShell encoding issues
|
||||
def props = readProperties file: 'gradle.properties'
|
||||
def currentVer = props['PUBLISH_VERSION'] ?: '0.1.0'
|
||||
// Read version using powershell with explicit encoding
|
||||
def verLine = bat(
|
||||
script: '@powershell -NoProfile -Command "[Console]::OutputEncoding=[Text.Encoding]::ASCII; (Get-Content gradle.properties | Select-String \'PUBLISH_VERSION\').ToString().Split(\'=\')[1].Trim()"',
|
||||
returnStdout: true
|
||||
).trim()
|
||||
def currentVer = verLine ?: '0.1.0'
|
||||
echo "Current PUBLISH_VERSION: ${currentVer}"
|
||||
|
||||
def parts = currentVer.tokenize('.')
|
||||
while (parts.size() < 3) { parts.add('0') }
|
||||
def major = parts[0].toInteger()
|
||||
def minor = parts[1].toInteger()
|
||||
def patch = parts[2].toInteger()
|
||||
|
||||
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
|
||||
case 'major': major++; minor = 0; patch = 0; break
|
||||
case 'minor': minor++; patch = 0; break
|
||||
case 'patch': default: patch++; break
|
||||
}
|
||||
def newVer = parts.join('.')
|
||||
def newVer = "${major}.${minor}.${patch}"
|
||||
echo "Auto-bumped PUBLISH_VERSION: ${currentVer} → ${newVer}"
|
||||
env.NEW_VERSION = newVer
|
||||
|
||||
// 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
|
||||
// Write back using powershell
|
||||
bat "powershell -Command \"(Get-Content gradle.properties) -replace '^PUBLISH_VERSION=.*', 'PUBLISH_VERSION=${newVer}' | Set-Content -NoNewline gradle.properties\""
|
||||
|
||||
def modules = env.PUBLISH_MODULES.split(',').toList()
|
||||
def versionMap = [:]
|
||||
@ -120,6 +115,7 @@ pipeline {
|
||||
steps {
|
||||
script {
|
||||
bat """
|
||||
git checkout main
|
||||
git config user.email "jenkins@xuqm.com"
|
||||
git config user.name "Jenkins CI"
|
||||
git add gradle.properties
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户