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

No history reported for PRs when merging is enabled and workspace is wiped out

XMLWordPrintable

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

      git-plugin does not report history for PRs when strategy "Merging the pull request with the current target branch revision" is enabled and the workspace is wiped out before checkout (using "Wipe out repository & force clone" option for example). The merge should be non-fast-forward to observe this issue.

      With the following repo as an example (test-branch is a PR branch with master as target):

      * e1debe8 (HEAD -> test-branch, origin/test-branch) third test
      * 10ce9b6 Second test
      * ad86793 First test
      | * a7f15db (origin/master, master) Add change to master to make merges non-ff
      |/
      * 3e86175 Fix jenkinsfile again
      * 1643e81 Fix jenkinsfile
      * 4f4d86c Add simple Jenkinsfile 

      Building 10ce9b6 with current master works with no problem first time (build #3, note non-fast-forward merge):

      Merging remotes/origin/master commit a7f15db4ea40de685f700822e7c70f0672ac0c2d into PR head commit 10ce9b695a0c40785361caa44e223c3c941f3e47
      ...
      Merge succeeded, producing 671ff86181f0b8ac96385c3521da53949155f646 

      After that while building e1debe8 Jenkins cannot produce changelog (build #4):

      Merging remotes/origin/master commit a7f15db4ea40de685f700822e7c70f0672ac0c2d into PR head commit e1debe80f411776930a8d31e5881a893b791ced1
      ...
      Merge succeeded, producing 12136815f05477c42305659f7d4e73e8d3bea555
      ...
       > git rev-list --no-walk 671ff86181f0b8ac96385c3521da53949155f646 # timeout=10
      First time build. Skipping changelog. 

      Note that git-plugin tries to find merge commit from the previous build, it does not exist in the workspace because it was previously wiped out. Note that wipeout repository option makes this bug easy to reproduce, but this could also happen when building on different nodes, when some of them will not have repository from all previous builds.

      The problem seems to be located here: https://github.com/jenkinsci/git-plugin/blob/18d14466c63f62fdf070258eb35a97f6cb22513b/src/main/java/hudson/plugins/git/GitSCM.java#L1318, where not action is performed to ensure that merge commit for previous build is present in the repo.

      The example repo referenced in the description is located here: https://github.com/eugmes/test, I am attaching build logs.

            Unassigned Unassigned
            ievgenii_meshcheriakov Ievgenii Meshcheriakov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: