[JIRA] (JENKINS-58178) Git Plugin fails to mergeBeforeBuild with "ambiguous argument"

8 views
Skip to first unread message

bj.cardon@gmail.com (JIRA)

unread,
Jun 25, 2019, 3:44:01 AM6/25/19
to jenkinsc...@googlegroups.com
Ben Cardon created an issue
 
Jenkins / Bug JENKINS-58178
Git Plugin fails to mergeBeforeBuild with "ambiguous argument"
Issue Type: Bug Bug
Assignee: Mark Waite
Components: git-plugin, workflow-scm-step-plugin
Created: 2019-06-25 07:43
Environment: Jenkins 2.176.1 Git Plugin 4.0.0-rc
Priority: Minor Minor
Reporter: Ben Cardon

Hello, we have a Blue Ocean pipeline that is failing on the checkout step and we can't seem to figure out what the issue is. 

Our checkout step looks like

checkout([                    
  $class: 'GitSCM',                    
  branches: scm.branches,                    
  extensions: scm.extensions + [[$class: 'WipeWorkspace'], [$class: 'LocalBranch'], [$class: 'PreBuildMerge', options: [mergeStrategy: 'RESOLVE', mergeRemote: 'origin', mergeTarget: 'master']]],                    
  userRemoteConfigs: scm.userRemoteConfigs                
])

 

The error that is happening in the pipeline is

using credential github
Wiping out workspace first.
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository https://github.com/sample/myrepo.git
 > git init /usr/local/jenkins/workspace/repo_update_pipeline # timeout=10
Fetching upstream changes from https://github.com/sample/myrepo.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials GitHub Access Token
 > git fetch --no-tags --progress https://github.com/sample/myrepo.git +refs/heads/update_pipeline:refs/remotes/origin/update_pipeline # timeout=10
Cleaning workspace
Fetching without tags
 > git config remote.origin.url https://github.com/sample/myrepo.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/update_pipeline:refs/remotes/origin/update_pipeline # timeout=10
 > git config remote.origin.url https://github.com/sample/myrepo.git # timeout=10
 > git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
 > git clean -fdx # timeout=10
Fetching upstream changes from https://github.com/sample/myrepo.git
using GIT_ASKPASS to set credentials GitHub Access Token
 > git fetch --no-tags --progress https://github.com/sample/myrepo.git +refs/heads/update_pipeline:refs/remotes/origin/update_pipeline # timeout=10
Merging Revision 842081ddebb2be48b43005b7dccf5e26a1cbb04a (update_pipeline) to origin/master, UserMergeOptions{mergeRemote='origin', mergeTarget='master', mergeStrategy='RESOLVE', fastForwardMode='FF'}
Command "git rev-parse origin/master^{commit}" returned status code 128:
stdout: origin/master^{commit}

stderr: fatal: ambiguous argument 'origin/master^{commit}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:'git <command> [<revision>...] -- [<file>...]'

I believe the issue is that the pipeline is not fetching the master branch when performing the initial clone or any following step, but I've tried a number of config settings to try to entice it to pull master for merging.

Am I missing something or is there a bug in this behavior? Based on the Snippet Generator, this not what I would expect the behavior to be based on the available options.

For what it's worth, I am attempting to get the PreBuildMerge plugin working properly, we want to stage merging our branch into master and run the pipeline on the merged code which seems to work whenever master happens to exist in the branch workspace but not when it's a clean clone.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

mark.earl.waite@gmail.com (JIRA)

unread,
Jun 25, 2019, 7:24:03 AM6/25/19
to jenkinsc...@googlegroups.com
Mark Waite commented on Bug JENKINS-58178
 
Re: Git Plugin fails to mergeBeforeBuild with "ambiguous argument"

Merge is best done through the branch source plugins (GitHub, Bitbucket, and Gitea) rather than through the git plugin. The branch source plugins provide options to evaluate pull requests and they provide the necessary configuration to support the evaluation of pull requests.

If your environment won't allow you to use one of those branch source plugins, then the refspec used in the checkout needs to be extended to include the branch that is being merged in addition to the branch that is being built. Your example log lists:

 > git fetch --no-tags --progress https://github.com/sample/myrepo.git +refs/heads/update_pipeline:refs/remotes/origin/update_pipeline # timeout=10

That statement uses a narrow refspec that pulls only the branch being built ( update_pipeline ) and no other branches. That reduces the impact of the CI job on the remote server by requesting only the data needed for that specific branch. It also means that other branches are not available in the workspace repository.

You'll need to either use the GitHub branch source plugin (preferred) or adjust the remote config that is currently listed as:

userRemoteConfigs: scm.userRemoteConfigs

mark.earl.waite@gmail.com (JIRA)

unread,
Jun 25, 2019, 7:25:01 AM6/25/19
to jenkinsc...@googlegroups.com
Change By: Mark Waite
Status: Open Fixed but Unreleased
Resolution: Not A Defect

mark.earl.waite@gmail.com (JIRA)

unread,
Jun 25, 2019, 7:25:01 AM6/25/19
to jenkinsc...@googlegroups.com
Mark Waite assigned an issue to Unassigned
Change By: Mark Waite
Assignee: Mark Waite

mark.earl.waite@gmail.com (JIRA)

unread,
Jan 28, 2020, 4:24:04 AM1/28/20
to jenkinsc...@googlegroups.com
Change By: Mark Waite
Status: Fixed but Unreleased Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages