diff --git a/Jenkinsfile b/Jenkinsfile index c30ac2c..bd30242 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,6 @@ pipeline { agent any parameters { - string(name: 'BRANCH', defaultValue: 'main', description: 'Git 分支名') string(name: 'VERSION', defaultValue: '', description: '发布版本号(留空使用 gradle.properties 中的 PUBLISH_VERSION)') booleanParam(name: 'RUN_TESTS', defaultValue: true, description: '是否运行自动化测试') booleanParam(name: 'PUBLISH', defaultValue: true, description: '是否发布到 Nexus') @@ -16,7 +15,12 @@ pipeline { stages { stage('Checkout') { steps { - checkout scm + checkout([ + $class: 'GitSCM', + branches: [[name: 'main']], + extensions: [[$class: 'CleanBeforeCheckout']], + userRemoteConfigs: scm.userRemoteConfigs + ]) script { if (params.VERSION?.trim()) { bat "powershell -Command \"(Get-Content gradle.properties) -replace '^PUBLISH_VERSION=.*', 'PUBLISH_VERSION=${params.VERSION}' | Set-Content gradle.properties\"" @@ -93,10 +97,7 @@ pipeline { stage('Publish to Nexus') { when { - allOf { - branch 'main' - expression { return params.PUBLISH } - } + expression { return params.PUBLISH } } steps { script {