How to auto merge Git branches prior to a Jenkins build?
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
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"
]
]