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 (https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin) 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.

 

 

 

Importing a project into github

We’re moving our development projects into github, so we wanted to get a copy of the code (checked out of Subversion) into a new project in github.

Here are the steps (assumes that you’ve set up your ssh keys correctly, according to e.g. http://help.github.com/linux-set-up-git/)

Setup the git globals:

$ git config --global user.name "Julian Higman"
$ git config --global user.email "jh @ kasabi.com"

Create the new project, add a README file, and connect it to the github remote project:

$ mkdir my-new-project
$ cd my-new-project/
$ git init
$ touch README
$ git add README
$ git commit -m "First commit"
$ git remote add origin git@github.com:kasabi/my-new-project.git
$ git push -u origin master

Now copy in the project source files, excluding svn files and other project config files:

$ cd ..
$ rsync -r --exclude=.svn --exclude=.buildpath --exclude=.project --exclude=.git my-old-project/ my-new-project/

Then add the new files, commit them, and push to the remote repo:

$ cd my-new-project/
$ git add -A
$ git status
$ git commit -m "added project files"
$ git push