Jenkins 中使用 流水线 获取 Git 的分支

插件简介

Git Parameter:增加了从项目中配置的git存储库中选择分支、标记或修订的能力。

插件安装

系统管理-插件管理安装此插件Git Parameter 插件

插件使用

在这里插入图片描述
☑ 新增一个Git参数
在这里插入图片描述
☑ 流水线代码如下

parameters {
    
    
  gitParameter branch: '', branchFilter: 'origin/(.*)', defaultValue: '', description: '请选择要发布的代码分支或标签名称,默认值:', name: 'BRANCH', quickFilterEnabled: true, selectedValue: 'DEFAULT', sortMode: 'NONE', tagFilter: '*', type: 'GitParameterDefinition', useRepository: 'URL'
}

问题
使用界面或者流水线第一次构建后,会报错,提示未找到分支,再构建一次即可正常显示动态获取到的分支
Is this the end of our lives? Can’t still spell

猜你喜欢

转载自blog.csdn.net/qq_50573146/article/details/125392064