pipeline 顯示獲取git分支

技术颜良發表於2024-07-10

pipeline {
agent any
parameters {
gitParameter(
branchFilter: 'origin/(.*)', //高階中設定為這個
defaultValue: 'master',
name: 'BRANCH',
type: 'PT_BRANCH',
useRepository: 'https://gitlab.lingtingshidai.com/lt/java/lt-comment-service.git'
)
}
stages {
stage('Checkout') {
steps {
git branch: "${params.BRANCH}", credentialsId: '0f085850-1868-454d-8520-f59542af257f', url: 'https://gitlab.lingtingshidai.com/lt/java/lt-comment-service.git'

        }
    }
    stage('Build') {
        steps {
            script {
              sh 'source /etc/profile && /usr/local/jenkins/apache-maven-3.6.3/bin/mvn clean package -U -Dmaven.test.skip=true -B'
            }
        }
    }
}

}

相關文章