diff --git a/Jenkinsfile b/Jenkinsfile index 2e1a9a3..2832c19 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: '发布版本号(留空自动递增)') booleanParam(name: 'RUN_TESTS', defaultValue: true, description: '是否运行单元测试') booleanParam(name: 'PUBLISH_SPM', defaultValue: true, description: '发布 SPM 版本(打 Git Tag)') @@ -23,7 +22,12 @@ pipeline { stages { stage('Checkout') { steps { - checkout scm + checkout([ + $class: 'GitSCM', + branches: [[name: 'main']], + extensions: [[$class: 'CleanBeforeCheckout']], + userRemoteConfigs: scm.userRemoteConfigs + ]) script { env.GIT_COMMIT_SHORT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() if (params.VERSION?.trim()) { @@ -74,10 +78,7 @@ pipeline { stage('Publish SPM (Git Tag)') { when { - allOf { - branch 'main' - expression { return params.PUBLISH_SPM } - } + expression { return params.PUBLISH_SPM } } steps { withCredentials([usernamePassword(credentialsId: 'gitlab-credentials', passwordVariable: 'GIT_PASS', usernameVariable: 'GIT_USER')]) { @@ -95,10 +96,7 @@ pipeline { stage('Publish CocoaPods') { when { - allOf { - branch 'main' - expression { return params.PUBLISH_PODS } - } + expression { return params.PUBLISH_PODS } } steps { sh """