pipeline git参数化构建

1.插件

git parameter

2.代码

pipeline {
parameters {
    gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'BRANCH', type: 'PT_BRANCH'
    choice choices: ['dev', 'test'], name: 'NAMESPACE'
}
options {
    buildDiscarder(logRotator(numToKeepStr: '15'))
    timestamps()
    timeout(time:1, unit:'HOURS')
}    
    agent 
        {label 'jnlp-slave'}
    stages {
        stage('set buildDescription') {
            steps {
                script {
                        buildName ("${JOB_NAME}-${env.BUILD_NUMBER}")
                        buildDescription ("部署环境: ${params.NAMESPACE} \n 代码分支:${params.BRANCH}")
                    }
                }
            }           
        stage('Source') {
            steps {
                //sh 'git clone http://192.168.90.170:32187/root/demo-java.git'
                git branch: "${params.BRANCH}", url: 'http://192.168.90.170:32187/root/demo-java.git'
            }
        }
  }

3.构建选择

4.构建完成

posted @ 2022-04-06 12:40  等等马上就好  阅读(713)  评论(0编辑  收藏  举报