Reputation: 361
I Want to create a JOB that have as parameters the name of the repository, and once this parameter is set, then the second parameter (branches) is shown as list of available GIT branches in the selected repository.
Thank for your help. Reda.
Upvotes: 1
Views: 596
Reputation: 8267
You can get these parameters using this Groovy code:
Get repository name:
def rpository_name = scm.getUserRemoteConfigs()[0].getUrl().tokenize('/')[3].split("\\.")[0]
Get list branches:
def branches = git for-each-ref refs/heads/ --format='%(refname:short)'
If this code is not working you can use this script: Jenkins groovy script which lists remote branches. Raw
Upvotes: 1