2014-01-16 22 views

回答

1

對於hgweb停Mercurial的庫列表中它的分支可以從REPO-URL/branches?style=raw

獲得見https://www.mercurial-scm.org/repo/hg/branches?style=raw輸出作爲樣本。

+0

要解析這個輸出,你可以這樣做:'' def branches = new URL('http://selenic.com/hg/branches?style=raw').text.split('\ n')*。split()*。head()' –

0

您可以使用Extended choice parameter plugin具有以下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命令
  • 我提供的用戶+密碼認證僅作爲示例