Jenkins – Active Choice: Git branch


For a parameterized build with branch selection, you will need a plugin Active Choices

Go to Jenkins settings


Section “Manage Plugins


Go to the “Available” tab and specify “Active Choice” in the search.

Install it.

Create a “New Item” – “Pipeline“, indicate that it will be a parameterized project, and add the parameter “Active Choices Reactive Parameter


We indicate that this is “Groovy Script” and paste the following into it:

def gettags = ("git ls-remote -t -h ssh://").execute()
return gettags.text.readLines().collect { 
  it.split()[1].replaceAll('refs/heads/', '').replaceAll('refs/tags/', '').replaceAll("\\^\\{\\}", '')


Where “ssh: //” is the path to your repository. Jenkins must have access to this repository over SSH



Now, when building with parameters, there will be a branch selection

Tagged: Tags

Notify of

Inline Feedbacks
View all comments