简体   繁体   English

如何在 Jenkins 中为 Active Choices Reactive Parameter 插件设置默认值?

[英]How to set default value for Active Choices Reactive Parameter plugin in Jenkins?

I'm using the following Groovy code snippet for listing all the git branches in particular git repo and I can get that list successfully.我正在使用以下 Groovy 代码片段来列出所有 git 分支,特别是 git 存储库,我可以成功获取该列表。 But how can I set a default value for this list?但是我怎样才能为这个列表设置一个默认值呢? I'm trying to set master as default value.我正在尝试将master设置为默认值。

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("\\^\\{\\}", '')
}

Here you can use the option selected for the default value 'master:selected' and then return the list.在这里,您可以使用为默认值'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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM