Skip to content

Instantly share code, notes, and snippets.

@dkoudlo
Last active March 24, 2017 18:38
Show Gist options
  • Save dkoudlo/551c15fb1be689231bb2eb7ed2d55324 to your computer and use it in GitHub Desktop.
Save dkoudlo/551c15fb1be689231bb2eb7ed2d55324 to your computer and use it in GitHub Desktop.
Get Git Branches Names - Usefull to run on jenkins
def defaultBranch = 'master'
def sshLinkToRepo = 'ssh://git@github.com/dkoudlo/py-manage-server.git'
def gettags = ("git ls-remote -t -h " + sshLinkToRepo + " refs/heads/*").execute()
def branchNames = [defaultBranch] + gettags.text.readLines().collect { it.split()[1].replaceAll('refs/heads/', '') }
return branchNames.unique()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment