How to auto merge Git branches prior to a Jenkins build?
I have 2 builds, one for branch master
and one for production.
I would like to do Git merge <
You can do premerging via extensions block in pipelines (assuming you configured checkout: [ $class: 'GIT_SCM' ]
already.)
[
$class: "PreBuildMerge",
options: [
mergeTarget: "master",
fastForwardMode: "FF",
mergeRemote: "origin",
mergeStrategy: "OURS"
]
]
That's supported by the latest Git Plugin on Jenkins. Just set "Checkout/merge to local branch" to "production" under the Advanced settings for Git in the Job configuration. Then set the "Branches to build" to master, or just leave it blank to have Jenkins try and merge and build each other branch it finds to production. It will do one merge/build for each branch. It can also push the merged branch back to the source it pulled from.
Check this out: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-AdvancedFeatures