title: Git branch select in Jenkins with groovy script
body: <p>I am trying to make a <code>Parameterized build</code> in Jenkins. In this way user can choose the git branch he/she wants to deploy from a cascade menu.</p>
  
  <p>There are two possible ways:</p>
  
  <ol>
  <li><p>Writing branch names in file and configuring Jenkins to read this file (<code>project configuration &gt;   extend choice parameter and selecting Property file</code>).</p>
  
  <p>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, <em>you have to update the file containing the available branch name updated</em>. This needs a scheduled job by cron and I am not allowed using this approach.<br/></p></li>
  <li><p>Using Groovy script (<code>project configuration &gt; extend choice parameter and selecting "Groovy script"</code>). Then you need a groovy script to retrieve the branch name as follows: <code>branches=master,feature/Feature-1,feature/Feature-2,hotfix/Hotfix-1,release/Release-1</code>.</p></li>
  </ol>
  
  <p>I found a groovy script in <a href="https://stackoverflow.com/questions/10433105/dynamically-fill-jenkins-choice-parameter-with-git-branches-in-a-specified-repo">here</a> but it doesn't work. I have installed groovy on my machine.</p>
  
  <p>Can anybody help me? To make the story short: I need a groovy script which returns the available branch names of a remote repository.</p>