1

I started investigating the GitSCM class in Jenkins, so I see the parameters it takes in the constructor. There's only one thing I don't understand: The branches parameter is of type: List<BranchSpec> branches.

My question is: why does it take a list of branches? why would I checkout a list of branches in the checkout step?

YoavKlein
  • 2,005
  • 9
  • 38

1 Answers1

1

It is not the banches you want to checkout. These are the branches you want to build.

In jenkins.io documentation it says:

Specify the branches if you'd like to track a specific branch in a repository. If left blank, all branches will be examined for changes and built.

So if you just want master and feature1 branch tracked, use refs/heads/master, refs/heads/feature1 or let it blank for building all branches.

S.Spieker
  • 7,005
  • 8
  • 44
  • 50
  • What do you mean by "These are branches you want to build"? What is to "build a branch" if not checking out the branch and then build the code in it? – YoavKlein Jan 02 '21 at 19:50
  • It will just check for the branches you list here, the rest will not be checked out nor built. If you need all, just keep it empty. – S.Spieker Jan 02 '21 at 21:35