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://git-codecommit.eu-west-1.amazonaws.com/v1/repos/artem-services.git").execute()
return gettags.text.readLines().collect { 
  it.split()[1].replaceAll('refs/heads/', '').replaceAll('refs/tags/', '').replaceAll("\\^\\{\\}", '')
}

 

Where "ssh: //git-codecommit.eu-west-1.amazonaws.com/v1/repos/artem-services.git" 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

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments