Make Jenkins test merge result of branches

Almost all of the time we are writing code to be merged into master
sooner rather than later. Rather than testing the HEAD of the branch in
Jenkins this commit adds a script which merges the branch with master
before building it.