Skip to content

Instantly share code, notes, and snippets.

@perfectfoolish
Last active September 6, 2017 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perfectfoolish/1ca13195b12fd8c2217ff0c031f0c923 to your computer and use it in GitHub Desktop.
Save perfectfoolish/1ca13195b12fd8c2217ff0c031f0c923 to your computer and use it in GitHub Desktop.
Install 'Extended Choice Parameter Plug-In', then selected 'Basic Parameter Types', input 'Number of Visible Items' with 100 and 'Delimiter' with ',', selected Groovy Script and input this script.
def gitURL = "git@github.com:xxxxx.git"
def command = "git ls-remote -h $gitURL"
def proc = command.execute()
proc.waitFor()
if ( proc.exitValue() != 0 ) {
return ["develop", "master"]
}
def branches = proc.in.text.readLines().collect {
it.replaceAll(/[a-z0-9]*\trefs\/heads\//, '')
}
branches -= ["develop", "master"]
branches = ["develop", "master"] + branches
return branches.join(",")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment