Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save eeichinger/9761870 to your computer and use it in GitHub Desktop.
Save eeichinger/9761870 to your computer and use it in GitHub Desktop.
Groovy script to list git tags and branches using jenkins' Dynamic Choices Parameter plugin
def gettags = ("git ls-remote -t -h ssh://jenkins@<mygitpath>/repo/some.git feature/*").execute()
return gettags.text.readLines()
.collect { it.split()[1].replaceAll('refs/heads/', '') }
.unique()
.findAll { it.startsWith('<some more pattern>') }
@mcote57
Copy link

mcote57 commented Aug 21, 2018

I would like to use this code in jenkins to get the list of branches, but I would like my default branch to always show up first in the list. I cannot figure out how to do this. Any help is appreciated.

@ddutka-creatision
Copy link

the result of this script is the list of branches. How do i get the list of remote tags though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment