Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在groovy中生成mercurial分支列表?_Groovy_Mercurial_Jenkins - Fatal编程技术网

如何在groovy中生成mercurial分支列表?

如何在groovy中生成mercurial分支列表?,groovy,mercurial,jenkins,Groovy,Mercurial,Jenkins,如何在groovy中生成远程mercurial分支列表?我想在Jenkins中添加动态选择器参数。Mercurial服务器作为hgweb运行。对于hgweb服务,Mercurial的分支库列表可从REPO-URL/branchs?style=raw 请参见作为示例的输出。您可以将与以下Groovy脚本一起使用: def hgUser = "user" def hgPassword = "password" def hgUrl = "repo_url" def args = [ "wge

如何在groovy中生成远程mercurial分支列表?我想在Jenkins中添加动态选择器参数。Mercurial服务器作为hgweb运行。

对于hgweb服务,Mercurial的分支库列表可从
REPO-URL/branchs?style=raw

请参见作为示例的输出。

您可以将与以下Groovy脚本一起使用:

def hgUser = "user"
def hgPassword = "password"
def hgUrl = "repo_url"

def args = [
    "wget",
    "-q",
    "-O",
    "-",
    "https://" + hgUser + ":" + hgPassword + "@" + hgUrl + "/branches?style=raw"
];
def builder = new ProcessBuilder(args)
builder.redirectErrorStream(true)
def process = builder.start()

def branches = process.text.split("\n")*.split().findAll{
    it[2] != "closed" // Retain only non-closed branches
}*.head()
return branches.join(',')
注意

  • 脚本调用
    wget
    命令
  • 我提供的用户+密码身份验证只是一个示例

要解析此输出,可以执行以下操作:
def branchs=newurl('http://selenic.com/hg/branches?style=raw').text.split('\n')*.split()*.head()