I've found groovy script for this. A bit modified it. You need to select 'groovy script' instead of 'Property file'
def gitURL = "ssh://jenkins@phabricator.com/project.git"
def command = "git ls-remote -h $gitURL"
def proc = command.execute()
proc.waitFor()
if ( proc.exitValue() != 0 ) {
println "Error, ${proc.err.text}"
System.exit(-1)
}
def branches = proc.in.text.readLines().collect {
it.replaceAll(/[a-z0-9]*refs/heads//, '')
}
return branches.join(",")
Idea is the same. Only now your key is ${Branch} in the job. Works well. Huge thanks @Technext for idea.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…