Jenkins List Git Branches插件 构建选择指定git分支

  • 阿里云国际版折扣https://www.yundadi.com

  • 阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

    List Git Branches Parameter | Jenkins pluginAdds ability to choose from git repository revisions or tagsicon-default.png?t=N7T8https://plugins.jenkins.io/list-git-branches-parameter/

    1、安装组件  List Git Branches


    2、验证功能


    1新建任务 

    2新增构建参数 

    3选择git仓库
    我这里选择gitee其他类似。仓库如果不是公开的需要配置key 

    4jenkins配置git仓库

    5开始构建
    点击【build with praameters】可以选择git分支版本了

    6优化git分支名称
    选择【配置】—>【高级】,在【branch filter】添加“refs/heads/(.*)”点击保存

    选择【build with parameters】分支名称更简洁了

     最后拿到分支了就是去拉取指定分支的代码了注意这里是"${env.BRANCH}"而不是单引号

    pipeline {
        agent any
    
        stages {
            stage('Hello') {
                steps {
                    script{
                        print(env.BRANCH)
                        checkout([$class: 'GitSCM', branches: [[name: "${env.BRANCH}"]], extensions: [], userRemoteConfigs: [[credentialsId: '33375fd1-0418-4b7a-a65e-4ffcebd8e7da', url: 'http://192.168.11.129/root/devops-maven-service.git']]])                   
                    }
                }
            }
        }
    }
    
  • 阿里云国际版折扣https://www.yundadi.com

  • 阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6