Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58178

Git Plugin fails to mergeBeforeBuild with "ambiguous argument"

XMLWordPrintable

      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.

            Unassigned Unassigned
            cardonator Ben Cardon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: