Jenkins - how to build a specific branch

ffxsam picture ffxsam · Aug 20, 2015 · Viewed 144.3k times · Source

This isn't as simple as just doing a parametrized build. I've already got a specific build process that will build and deploy whenever any of these branches are pushed to GitHub:

enter image description here

So if I've just pushed develop and it built successfully, how do I trigger a manual build and have it pull feature/my-new-feature (without doing a git push)? I tried enabling parametrized build, adding a new string called branch, and then adding a new branch specifier, */$branch. I then ran a build and set branch to feature/my-new-feature and it still pulled from develop.

I'd appreciate any help!

Answer

Ranjith's picture Ranjith's · Nov 3, 2016

Best solution can be:

Add a string parameter in the existing job enter image description here

Then in the Source Code Management section update Branches to build to use the string parameter you defined enter image description here

If you see a checkbox labeled Lightweight checkout, make sure it is unchecked.

The configuration indicated in the images will tell the jenkins job to use master as the default branch, and for manual builds it will ask you to enter branch details (FYI: by default it's set to master)enter image description here