I am trying to make a Parameterized build
in Jenkins. In this way user can choose the git branch he/she wants to deploy from a cascade menu.
There are two possible ways:
Writing branch names in file and configuring Jenkins to read this file (
project configuration > extend choice parameter and selecting Property file
).Problem : You have to make a local repository as a mirror of remote repo and keep this local repo in sync with remote repo. In the other words, you have to update the file containing the available branch name updated. This needs a scheduled job by cron and I am not allowed using this approach.
Using Groovy script (
project configuration > extend choice parameter and selecting "Groovy script"
). Then you need a groovy script to retrieve the branch name as follows:branches=master,feature/Feature-1,feature/Feature-2,hotfix/Hotfix-1,release/Release-1
.
I found a groovy script in here but it doesn't work. I have installed groovy on my machine.
Can anybody help me? To make the story short: I need a groovy script which returns the available branch names of a remote repository.