Christian
Christian

Reputation: 519

How do I properly use the "branch" option of the Jenkins's git parameter plugin?

I set up the simple Jenkins project shown below. All I'm trying to do in this minimal working example is to have a git repository whose branch I can choose when triggering a job manually.

The real project is also supposed to automatically build a set of branches matching a regex on origin updates and build each branch in its own workspace but those are actually the parts that are working.

For some reason, however, the branch that's built is always the one with the latest commit, not the one selected as the branch or tag parameter of the build. So for the given repository, selecting master will still build branch1 because that's where the latest commit happened.

All the settings seem simple enough so I don't see where I've made a mistake and I'd appreciate any help.

I'm using Jenkins 2.143 and the Git Parameter Plug-In 0.9.5. Project settings

Upvotes: 2

Views: 3197

Answers (1)

BOC
BOC

Reputation: 1699

You need to tell the Source Code Management configuration to use the branch you select using the Git parameter. Your parameter name is BRANCH_OR_TAG, so you need to use that for the Branches to build -> Branch specifier. Change ** to ${BRANCH_OR_TAG} and it should start building based on your selection.

Bit of explanation: the git parameter plugin only knows how to go out and get the list of branches, then put the selected value into a variable (which is basically how all Jenkins parameters work). It's up to you to tell the rest of the build job how/where to leverage that variable.

Upvotes: 5

Related Questions