Building github branches with Jenkins

We usually work on several parallel branches of a repo on github, and we wanted to be able to build and test any branch on demand.

So we set up a parameterised job in Jenkins that will take the name of a branch and run the build process.

As for all github builds, you need to have installed the git plugin first ( and set up your github globals in the Jenkins settings:




Then set up a parameterized build job with the repo as the GitHub project and with “branch” as the parameter to be specified:

and in the Source Code Management section, add the parameter to the “Branches to build”:

Don’t specify any build triggers – you’ll probably just want to run this on-demand against specific branches, rather than every time there’s a push to the repo (which is what happens by default).

Now you can build any branch just by giving the branch name as the required parameter when the job is started.




5 thoughts on “Building github branches with Jenkins”

  1. I have this error during my build. I am new with this Jenkins… Let me know how can I solve this problem:
    Checkout:workspace / /var/lib/jenkins/jobs/Pokitpal/workspace – hudson.remoting.LocalChannel@14c55164
    Using strategy: Default
    Checkout:workspace / /var/lib/jenkins/jobs/Pokitpal/workspace – hudson.remoting.LocalChannel@14c55164
    Fetching changes from the remote Git repository
    Fetching upstream changes from
    Commencing build of Revision bccb1185a524039f5906fbc15969b33105e04702 (origin/master)
    Checking out Revision bccb1185a524039f5906fbc15969b33105e04702 (origin/master)
    No change to record in branch origin/master
    [workspace] $ /bin/sh -xe /tmp/
    + git status
    # Not currently on any branch.
    nothing to commit (working directory clean)

  2. Is it possible todo both? Have a on-demand setup like what you described above and also use Build triggers (build when a change is pushed to Github)

  3. can i have a dropdown of all the available branches in the specific project which jenkins is trying to building so that i can select at the time of building..

  4. Pingback: [ASK] server - Jenkins build watch for new branches and build named branch | Some Piece of Information

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.