Anyone got this to work? I'm running this in context of the multibranch
pipeline plugin - so I'd like to get whatever branch is triggered to merge
into an integration-branch before building, then pushing back to the
integration branch if the build succeeds.
torsdag 7. april 2016 03.13.37 UTC+2 skrev Martin d'Anjou følgende:
>
> 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
> <https://gist.github.com/martinda/b2ece95c2c71ddb4d4a762f0a02561b3> and
> log <https://gist.github.com/martinda/985b2d69c3d5b96575178f65df309dfe>
> as github gists.
>
> Anyone tried this yet? Any ideas?
>
> Thanks,
> Martin
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/63b49311-0b10-4555-896c-731c4a1823d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.