【问题标题】:How to set default value for Active Choices Reactive Parameter plugin in Jenkins?如何在 Jenkins 中为 Active Choices Reactive Parameter 插件设置默认值?
【发布时间】:2020-06-04 12:15:31
【问题描述】:

我正在使用以下 Groovy 代码 sn-p 列出所有 git 分支,特别是 git repo,我可以成功获取该列表。但是我怎样才能为这个列表设置一个默认值呢?我正在尝试将 ma​​ster 设置为默认值。

def gettags = ("git ls-remote --heads git@org/sample-repo-service.git").execute()
def repoNameList = gettags.text.readLines().collect {
    it.split()[1].replaceAll('refs/heads/', '').replaceAll('refs/tags/', '').replaceAll("\\^\\{\\}", '')
}

【问题讨论】:

    标签: jenkins groovy jenkins-plugins jenkins-groovy


    【解决方案1】:

    这里可以使用为默认值'master:selected'选择的选项,然后返回列表。

    def gettags = ("git ls-remote --heads git@github.com:org/sample-repo-service.git").execute()
    def repoNameList = gettags.text.readLines().collect {
        it.split()[1].replaceAll('refs/heads/', '').replaceAll('refs/tags/', '').replaceAll("\\^\\{\\}", '')
    }
    repoNameList.add(0, 'master:selected')
    return repoNameList
    

    【讨论】:

      猜你喜欢
      • 2021-11-29
      • 2020-07-03
      • 1970-01-01
      • 1970-01-01
      • 2022-08-18
      • 2016-01-18
      • 1970-01-01
      • 2019-07-19
      • 1970-01-01
      相关资源
      最近更新 更多