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') {
|
stage('Resolve Versions') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
// Read version using Groovy to avoid PowerShell encoding issues
|
// Read version using powershell with explicit encoding
|
||||||
def props = readProperties file: 'gradle.properties'
|
def verLine = bat(
|
||||||
def currentVer = props['PUBLISH_VERSION'] ?: '0.1.0'
|
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}"
|
echo "Current PUBLISH_VERSION: ${currentVer}"
|
||||||
|
|
||||||
def parts = currentVer.tokenize('.')
|
def parts = currentVer.tokenize('.')
|
||||||
while (parts.size() < 3) { parts.add('0') }
|
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) {
|
switch (params.VERSION_BUMP) {
|
||||||
case 'major':
|
case 'major': major++; minor = 0; patch = 0; break
|
||||||
parts[0] = (parts[0].toInteger() + 1).toString()
|
case 'minor': minor++; patch = 0; break
|
||||||
parts[1] = '0'
|
case 'patch': default: patch++; break
|
||||||
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('.')
|
def newVer = "${major}.${minor}.${patch}"
|
||||||
echo "Auto-bumped PUBLISH_VERSION: ${currentVer} → ${newVer}"
|
echo "Auto-bumped PUBLISH_VERSION: ${currentVer} → ${newVer}"
|
||||||
env.NEW_VERSION = newVer
|
env.NEW_VERSION = newVer
|
||||||
|
|
||||||
// Write back using Groovy to avoid PowerShell encoding issues
|
// Write back using powershell
|
||||||
def content = readFile('gradle.properties')
|
bat "powershell -Command \"(Get-Content gradle.properties) -replace '^PUBLISH_VERSION=.*', 'PUBLISH_VERSION=${newVer}' | Set-Content -NoNewline 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 = [:]
|
||||||
@ -120,6 +115,7 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
bat """
|
bat """
|
||||||
|
git checkout main
|
||||||
git config user.email "jenkins@xuqm.com"
|
git config user.email "jenkins@xuqm.com"
|
||||||
git config user.name "Jenkins CI"
|
git config user.name "Jenkins CI"
|
||||||
git add gradle.properties
|
git add gradle.properties
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户