I'm trying to get the Git Plugin to merge a branch to master before build, in a Pipeline DSL script, but it's not convincingly working yet. After the checkout step has run, a quick "git log --graph" command does not reveal a merge. The Pipeline DSL code I have is:
node {
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
userRemoteConfigs: [[
name: 'origin',
refspec: 'pull-requests/1/from',
url: path
]],
extensions:
[[
$class: 'PreBuildMerge',
options: [
fastForwardMode: 'NO_FF',
mergeRemote: 'origin',
mergeStrategy: 'MergeCommand.Strategy',
mergeTarget: 'master'
]
]]
])
sh 'git log -n 10 --graph --pretty=oneline --abbrev-commit --all --decorate=full'
}
And the resulting log:
[Pipeline] checkout
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url /tmp/jenkins/upstream-repo # timeout=10
Fetching upstream changes from /tmp/jenkins/upstream-repo
> git --version # timeout=10
> git -c core.askpass=true fetch --tags --progress /tmp/jenkins/upstream-repo pull-requests/1/from
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/refs/heads/master^{commit} # timeout=10
Merging Revision 19e39345b1b178e3ebc4c5b3af277cbd64c37f9f (refs/remotes/origin/master) to origin/master, UserMergeOptions{mergeRemote='origin', mergeTarget='master', mergeStrategy='MergeCommand.Strategy', fastForwardMode='--no-ff'}
> git rev-parse origin/master^{commit} # timeout=10
> git config core.sparsecheckout # timeout=10
> git checkout -f origin/master
> git merge --no-ff 19e39345b1b178e3ebc4c5b3af277cbd64c37f9f # timeout=10
> git rev-parse HEAD^{commit} # timeout=10
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Seen branch in repository origin/pull-requests/1/from
Seen 3 remote branches
Checking out Revision 19e39345b1b178e3ebc4c5b3af277cbd64c37f9f (origin/master, origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 19e39345b1b178e3ebc4c5b3af277cbd64c37f9f
> git rev-list 19e39345b1b178e3ebc4c5b3af277cbd64c37f9f # timeout=10
> git rev-list 19e39345b1b178e3ebc4c5b3af277cbd64c37f9f # timeout=10
[Pipeline] sh
[workspace] Running shell script
+ git log -n 10 --graph --pretty=oneline --abbrev-commit --all --decorate=full
* 3644c2e (refs/remotes/origin/pull-requests/1/from, refs/remotes/origin/HEAD, refs/heads/pull-requests/1/from) Add file
* 19e3934 (HEAD, refs/remotes/origin/master, refs/heads/master) init
It should end with the git log showing a merge (3 commits), but it only shows two commits. Full
code and
log as github gists.
Anyone tried this yet? Any ideas?
Thanks,
Martin