列出 Jenkins 参数中的所有存储库分支

问题描述 投票:0回答:0

我正在尝试为 Jenkins 作业添加 Active choice 参数以填充所有 github 分支。我在 Jenkins 凭据中添加了个人访问令牌并尝试使用它。 所以,到目前为止,我已经尝试了以下片段。

def gettags = ("git ls-remote https://<username>@github.com/<username>/first-project.git").execute()
return gettags.text.readLines().collect { 
 it.split()[1].replaceAll('refs/heads/', '').replaceAll('refs/tags/', '').replaceAll("\\^\\{\\}", '')
}

但是,它不起作用,所以我尝试在 jenkins 脚本中执行并且它一直在运行,当我尝试只运行第一行时,它给了我

Result: Process[pid=17092, exitValue="not exited"]
,有人可以帮我吗?

github jenkins jenkins-pipeline jenkins-groovy git-remote
© www.soinside.com 2019 - 2024. All rights reserved.