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

Should fetch origin/refs even if repository exists in work tree

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-plugin
    • None

      Use case: Using git-plugin to run jobs on incoming pull requests, when the git repo exists in working tree, git-plugin fails to merge the branches because of a missing reference to the base branch.

      Behavior: git-plugin throws GitException
      Expected behavior: merge successfully the pr branch and the base branch

      Suggested solution: fetch origin references and not only the tags

      Stack trace:
      > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
      > git config remote.origin.url https://github.com/ros/bond_core.git # timeout=10
      Fetching upstream changes from https://github.com/ros/bond_core.git
      > git --version # timeout=10
      > git fetch --tags --progress https://github.com/ros/bond_core.git +refs/pull/:refs/remotes/origin/pr/
      > git rev-parse refs/remotes/origin/pr/31/merge^

      {commit} # timeout=10
      > git rev-parse refs/remotes/origin/origin/pr/31/merge^{commit}

      # timeout=10
      Merging Revision b0644a4eb62fde36776aae1a6ecd63a5a077838f (refs/remotes/origin/pr/31/merge) to origin/groovy-devel, UserMergeOptions

      {mergeRemote='origin', mergeTarget='groovy-devel', mergeStrategy='default', fastForwardMode='--ff'}

      > git rev-parse origin/groovy-devel^

      {commit} # timeout=10
      FATAL: Command "git rev-parse origin/groovy-devel^{commit}

      " returned status code 128:
      stdout: origin/groovy-devel^

      {commit}

      Workaround: wipe the workspace of the job

      Link to failing Jenkins job:
      http://build.ros.org/job/Ipr__bond_core__ubuntu_trusty_amd64/25/console

      This is my first issue on Jenkins please let me know if there is any missing information or if this is not the right way to describe an issue.
      Thanks!

      Edit: markewaite Sorry for the delay. For various reasons our buildfarm has an "old" version of Jenkins and some plugins. We're spinning up a new farm with the latest version of Jenkins and all plugins, I'll use that config to test and provide a reproducible example

          [JENKINS-46219] Should fetch origin/refs even if repository exists in work tree

          Mikael Arguedas created issue -
          Mikael Arguedas made changes -
          Summary Original: Should fetch origin/refs if workspace already exist New: Should fetch origin/refs even if repository exists in work tree
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]
          Mikael Arguedas made changes -
          Description Original: Use case: Using git-plugin to run jobs on incoming pull requests, when the git repo exists in working tree, git-plugin fails to merge the branches because of a missing reference to the base branch.

          Behavior: git-plugin throws GitException
          Expected behavior: merge successfully the pr branch and the base branch

          Suggested solution: fetch origin references and not only the tags

          Stack trace:
           > git rev-parse --is-inside-work-tree # timeout=10
          Fetching changes from the remote Git repository
           > git config remote.origin.url https://github.com/ros/bond_core.git # timeout=10
          Fetching upstream changes from https://github.com/ros/bond_core.git
           > git --version # timeout=10
           > git fetch --tags --progress https://github.com/ros/bond_core.git +refs/pull/*:refs/remotes/origin/pr/*
           > git rev-parse refs/remotes/origin/pr/31/merge^{commit} # timeout=10
           > git rev-parse refs/remotes/origin/origin/pr/31/merge^{commit} # timeout=10
          Merging Revision b0644a4eb62fde36776aae1a6ecd63a5a077838f (refs/remotes/origin/pr/31/merge) to origin/groovy-devel, UserMergeOptions{mergeRemote='origin', mergeTarget='groovy-devel', mergeStrategy='default', fastForwardMode='--ff'}
           > git rev-parse origin/groovy-devel^{commit} # timeout=10
          FATAL: Command "git rev-parse origin/groovy-devel^{commit}" returned status code 128:
          stdout: origin/groovy-devel^{commit}

          Workaround: wipe the workspace of the job

          Link to failing Jenkins job:
          http://build.ros.org/job/Ipr__bond_core__ubuntu_trusty_amd64/25/console

          This is my first issue on Jenkins please let me know if there is any missing information or if this is not the right way to describe an issue.
          Thanks!
          New: Use case: Using git-plugin to run jobs on incoming pull requests, when the git repo exists in working tree, git-plugin fails to merge the branches because of a missing reference to the base branch.

          Behavior: git-plugin throws GitException
          Expected behavior: merge successfully the pr branch and the base branch

          Suggested solution: fetch origin references and not only the tags

          Stack trace:
           > git rev-parse --is-inside-work-tree # timeout=10
          Fetching changes from the remote Git repository
           > git config remote.origin.url https://github.com/ros/bond_core.git # timeout=10
          Fetching upstream changes from https://github.com/ros/bond_core.git
           > git --version # timeout=10
           > git fetch --tags --progress https://github.com/ros/bond_core.git +refs/pull/*:refs/remotes/origin/pr/*
           > git rev-parse refs/remotes/origin/pr/31/merge^{commit} # timeout=10
           > git rev-parse refs/remotes/origin/origin/pr/31/merge^{commit} # timeout=10
          Merging Revision b0644a4eb62fde36776aae1a6ecd63a5a077838f (refs/remotes/origin/pr/31/merge) to origin/groovy-devel, UserMergeOptions{mergeRemote='origin', mergeTarget='groovy-devel', mergeStrategy='default', fastForwardMode='--ff'}
           > git rev-parse origin/groovy-devel^{commit} # timeout=10
          FATAL: Command "git rev-parse origin/groovy-devel^{commit}" returned status code 128:
          stdout: origin/groovy-devel^{commit}

          Workaround: wipe the workspace of the job

          Link to failing Jenkins job:
          http://build.ros.org/job/Ipr__bond_core__ubuntu_trusty_amd64/25/console

          This is my first issue on Jenkins please let me know if there is any missing information or if this is not the right way to describe an issue.
          Thanks!

          Edit: [~markewaite] Sorry for the delay. For various reasons our buildfarm has an "old" version of Jenkins and some plugins. We're spinning up a new farm with the latest version of Jenkins and all plugins, I'll use that config to test and provide a reproducible example
          pjdarton made changes -
          Attachment New: fails_when_git_folder_exists.txt [ 41993 ]
          Attachment New: success_when_no_git_folder_exists.txt [ 41994 ]
          pjdarton made changes -
          Attachment New: comparison_of_success_and_failure.png [ 41995 ]

            Unassigned Unassigned
            mikaelarguedas Mikael Arguedas
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: