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

Git plugin does not fetch branch to merge to when merge before build is used

    XMLWordPrintable

Details

    Description

      I am using MultiBranch Pipeline and performing git cloning like this when I detect in script that this build is building a PullRequest:

                              try {
                                  checkout([
                                      $class: 'GitSCM',
                                      branches: scm.branches,
                                      doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
                                      extensions: scm.extensions + [[$class: 'CloneOption', noTags: false, reference: '', shallow: false, depth: 0, timeout: 60], [$class: 'PruneStaleBranch'], [$class: 'CheckoutOption', timeout: 60], [$class: 'SubmoduleOption', recursiveSubmodules: true, timeout: 60], [$class: 'PreBuildMerge', options: [mergeRemote: 'origin', mergeTarget: targetBranch, fastForwardMode: ffMode]]],
                                      submoduleCfg: [],
                                      userRemoteConfigs: scm.userRemoteConfigs,
                                      browser: [$class: 'BitbucketWeb', repoUrl: 'https://bitbucket.org/microblink/core']
                                    ])
                              } catch (error) {
                                  currentBuild.result = 'FAILURE'
                                  echo "ERROR: Cannot perform git checkout due to git error or because branch does not merge cleanly!, Reason: '${error}'"
                                  sh 'false'
                              }
      

      scm is global variable defined by Multibranch Pipeline plugin and targetBranch is variable containing branch to which pull request is to (in my case this is 'master'). ffMode variable is set to 'FF_ONLY'

      This used to work two weeks ago, and now it stopped with following error:

      hudson.plugins.git.GitException: 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>...]'
      

      Indeed, if I cd into jenkins build dir on server and execute this command, I get the same error. Furthermore, If I execute 'git branch -a', I see no branches being fetched.

      This used to work before, but recently it stopped. Unfortunately, I cannot tell whether it stopped working due to update of jenkins, git plugin or git client plugin - downgrading any of it does not remove the issue.

      EDIT: This issue was fixed in v2.6.0, but reappeared in v3.0.0 and is still here in v3.0.5.

      Attachments

        Issue Links

          Activity

            dodoent Nenad Miksa created issue -
            dodoent Nenad Miksa made changes -
            Field Original Value New Value
            Component/s workflow-multibranch-plugin [ 21465 ]
            markewaite Mark Waite made changes -
            Assignee Mark Waite [ markewaite ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 173276 ] JNJira + In-Review [ 185037 ]
            markewaite Mark Waite made changes -
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Resolved [ 5 ]
            markewaite Mark Waite made changes -
            Link This issue duplicates JENKINS-36507 [ JENKINS-36507 ]
            dodoent Nenad Miksa made changes -
            Description I am using MultiBranch Pipeline and performing git cloning like this when I detect in script that this build is building a PullRequest:

            {code:java}
                                    try {
                                        checkout([
                                            $class: 'GitSCM',
                                            branches: scm.branches,
                                            doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
                                            extensions: scm.extensions + [[$class: 'CloneOption', noTags: false, reference: '', shallow: false, depth: 0, timeout: 60], [$class: 'PruneStaleBranch'], [$class: 'CheckoutOption', timeout: 60], [$class: 'SubmoduleOption', recursiveSubmodules: true, timeout: 60], [$class: 'PreBuildMerge', options: [mergeRemote: 'origin', mergeTarget: targetBranch, fastForwardMode: ffMode]]],
                                            submoduleCfg: [],
                                            userRemoteConfigs: scm.userRemoteConfigs,
                                            browser: [$class: 'BitbucketWeb', repoUrl: 'https://bitbucket.org/microblink/core&#39;]
                                          ])
                                    } catch (error) {
                                        currentBuild.result = 'FAILURE'
                                        echo "ERROR: Cannot perform git checkout due to git error or because branch does not merge cleanly!, Reason: '${error}'"
                                        sh 'false'
                                    }
            {code}

            scm is global variable defined by Multibranch Pipeline plugin and targetBranch is variable containing branch to which pull request is to (in my case this is 'master'). ffMode variable is set to 'FF_ONLY'

            This used to work two weeks ago, and now it stopped with following error:

            {code}
            hudson.plugins.git.GitException: 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>...]'
            {code}

            Indeed, if I cd into jenkins build dir on server and execute this command, I get the same error. Furthermore, If I execute 'git branch -a', I see no branches being fetched.

            This used to work before, but recently it stopped. Unfortunately, I cannot tell whether it stopped working due to update of jenkins, git plugin or git client plugin - downgrading any of it does not remove the issue.
            I am using MultiBranch Pipeline and performing git cloning like this when I detect in script that this build is building a PullRequest:

            {code:java}
                                    try {
                                        checkout([
                                            $class: 'GitSCM',
                                            branches: scm.branches,
                                            doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
                                            extensions: scm.extensions + [[$class: 'CloneOption', noTags: false, reference: '', shallow: false, depth: 0, timeout: 60], [$class: 'PruneStaleBranch'], [$class: 'CheckoutOption', timeout: 60], [$class: 'SubmoduleOption', recursiveSubmodules: true, timeout: 60], [$class: 'PreBuildMerge', options: [mergeRemote: 'origin', mergeTarget: targetBranch, fastForwardMode: ffMode]]],
                                            submoduleCfg: [],
                                            userRemoteConfigs: scm.userRemoteConfigs,
                                            browser: [$class: 'BitbucketWeb', repoUrl: 'https://bitbucket.org/microblink/core&#39;]
                                          ])
                                    } catch (error) {
                                        currentBuild.result = 'FAILURE'
                                        echo "ERROR: Cannot perform git checkout due to git error or because branch does not merge cleanly!, Reason: '${error}'"
                                        sh 'false'
                                    }
            {code}

            scm is global variable defined by Multibranch Pipeline plugin and targetBranch is variable containing branch to which pull request is to (in my case this is 'master'). ffMode variable is set to 'FF_ONLY'

            This used to work two weeks ago, and now it stopped with following error:

            {code}
            hudson.plugins.git.GitException: 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>...]'
            {code}

            Indeed, if I cd into jenkins build dir on server and execute this command, I get the same error. Furthermore, If I execute 'git branch -a', I see no branches being fetched.

            This used to work before, but recently it stopped. Unfortunately, I cannot tell whether it stopped working due to update of jenkins, git plugin or git client plugin - downgrading any of it does not remove the issue.

            EDIT: This issue was fixed in v2.6.0, but reappeared in v3.0.0 and is still here in v3.0.5.
            Environment ArchLinux, Jenkins 2.13, Git Plugin 2.5.2, Git Client Plugin 1.19.6 ArchLinux, Jenkins 2.48, Git Plugin 3.0.5, Git Client Plugin 2.2.1
            dodoent Nenad Miksa made changes -
            Assignee Mark Waite [ markewaite ]
            Resolution Fixed [ 1 ]
            Status Resolved [ 5 ] Reopened [ 4 ]
            markewaite Mark Waite made changes -
            Assignee Mark Waite [ markewaite ]
            dodoent Nenad Miksa made changes -
            Resolution Cannot Reproduce [ 5 ]
            Status Reopened [ 4 ] Closed [ 6 ]

            People

              Unassigned Unassigned
              dodoent Nenad Miksa
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: