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

Git plugin 2.0 "Recent Changes" is always empty in merge job

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Labels:
      None
    • Environment:
      Jenkins 1.509.4, Git plugin 2.0, Git client plugin 1.4.6, Debian Linux 7.2 ("Wheezy"), JDK 1.7.0u45 x64
    • Similar Issues:

      Description

      The "Recent Changes" list in merge jobs which use the Git plugin are now empty. Prior to Git plugin 2.0, the "Recent Changes" list showed those changes whose merge was attempted, whether the merge succeeded or not

      Steps to duplicate the problem (with apologies for the number of steps)

      1. Create a bare git repo on the master node as Jenkins user
        1. rm -rf /tmp/changes.git /tmp/changes
        2. git init --bare /tmp/changes.git
        3. echo "#! /bin/sh" > /tmp/changes.git/hooks/post-receive
        4. echo "curl --silent http://127.0.0.1:8080/git/notifyCommit?url=/tmp/changes.git" >> /tmp/changes.git/hooks/post-receive
        5. chmod a+x /tmp/changes.git/hooks/post-receive
        6. cd /tmp
        7. git clone changes.git
        8. cd changes
        9. echo "Git plugin 2.0 no longer shows changes from merges" > README
        10. git add README
        11. git commit -m "Add README to describe this repository" README
        12. git push origin master
      2. Create a Jenkins merge job using that bare git repo
        1. Create a new free-style software project "merge-changes"
        2. Restrict where this project can be run
          1. Label Expression: master
        3. Git source code management settings
          1. Repository URL: /tmp/changes.git
          2. Branches to build: */master*
        4. Additional behaviors: Merge before build
          1. Name of repository: origin
            1. (error on merge if this is blank - help says should use default, but didn't)
          2. Branch to merge to: master
        5. Poll SCM (for convenience with the git hook installed earlier)
          1. H * * * *
        6. Add post-build action: Git Publisher
          1. Git Publisher settings
            1. Merge results: Yes
            2. Branches:
              1. Branches to push: master
              2. Target remote name: origin
        7. Save the job
      3. Build Jenkins job
        1. curl --silent http://127.0.0.1:8080/job/merge-changes/build?delay=0sec
          1. Note that the "Recent Changes" will report no changes in any build
      4. Create new master-add-timestamp branch and commit from it
        1. git checkout -b master-add-timestamp
        2. date >> timestamp
        3. git add timestamp
        4. git commit -m "Add timestamp" timestamp
        5. git push origin master-add-timestamp
      5. Jenkins job runs, but "Recent Changes" still reports "No changes in any of the builds"
      6. Confirm master branch received the merge result
        1. git checkout master
        2. git pull
      7. Create new master-add-timestamp2 branch and commit from it
        1. git checkout -b master-add-timestamp2
        2. date >> timestamp2
        3. git add timestamp2
        4. git commit -m "Add new timestamp2" timestamp2
        5. git push origin master-add-timestamp2
        6. BUG: Merge will happen and be pushed, but no change listed
      8. Confirm master branch received the merge result
        1. git checkout master
        2. git pull

        Attachments

          Activity

          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Michael Lex
          Path:
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/54094393c170c94d330b1ae52101922092b0abd2
          Log:
          JENKINS-20392 Add test for Recent-History-Bug in merge-jobs.

          Compare: https://github.com/jenkinsci/git-plugin/compare/1dc2db5cb67c...54094393c170

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Michael Lex Path: src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/54094393c170c94d330b1ae52101922092b0abd2 Log: JENKINS-20392 Add test for Recent-History-Bug in merge-jobs. Compare: https://github.com/jenkinsci/git-plugin/compare/1dc2db5cb67c...54094393c170
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Michael Lex
          Path:
          src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java
          src/main/java/hudson/plugins/git/util/BuildData.java
          http://jenkins-ci.org/commit/git-plugin/b280169c2be71cc38a3302987a93920a067a40e7
          Log:
          JENKINS-20392 Fix "Recent History" for merge jobs.

          To compute the recent-history, jenkins uses a hashmap of branch-names
          and commit-ids. The bug has two sources:
          1) To fill the hashmap, jenkins uses only the branch-name and
          commit-ids of those commits, that triggered the build. The
          merge-commits created by jenkins are ignored (see
          BuildData.java#L129).
          2) To calculate the "Recent Changes", jenkins searches for the
          branch-names of the commit, that was built. But jenkins considers the
          merge-commit not part of any branch (the call to getRevisionsForSHA1
          in PreBuildMerge.java#L93 returns a Revision without associated
          branches).

          The patch fixes this bug by 1) including the branches of the current
          commit in the recent-changes-hashmap and 2) associating the current
          commit with the correct branch-name.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Michael Lex Path: src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java src/main/java/hudson/plugins/git/util/BuildData.java http://jenkins-ci.org/commit/git-plugin/b280169c2be71cc38a3302987a93920a067a40e7 Log: JENKINS-20392 Fix "Recent History" for merge jobs. To compute the recent-history, jenkins uses a hashmap of branch-names and commit-ids. The bug has two sources: 1) To fill the hashmap, jenkins uses only the branch-name and commit-ids of those commits, that triggered the build. The merge-commits created by jenkins are ignored (see BuildData.java#L129). 2) To calculate the "Recent Changes", jenkins searches for the branch-names of the commit, that was built. But jenkins considers the merge-commit not part of any branch (the call to getRevisionsForSHA1 in PreBuildMerge.java#L93 returns a Revision without associated branches). The patch fixes this bug by 1) including the branches of the current commit in the recent-changes-hashmap and 2) associating the current commit with the correct branch-name.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Michael Lex
          Path:
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/beab37d9c891bf88680e5ebdff56411d507e9797
          Log:
          JENKINS-20392 Add test for Recent-History-Bug in merge-jobs.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Michael Lex Path: src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/beab37d9c891bf88680e5ebdff56411d507e9797 Log: JENKINS-20392 Add test for Recent-History-Bug in merge-jobs.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java
          src/main/java/hudson/plugins/git/util/BuildData.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/7b1f340b37f8425ee3dea3e104727f456d53eb9f
          Log:
          Merge pull request #228 from mlex/master

          JENKINS-20392 Fix "Recent History" for merge jobs.

          Compare: https://github.com/jenkinsci/git-plugin/compare/f397b19b78f3...7b1f340b37f8

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java src/main/java/hudson/plugins/git/util/BuildData.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/7b1f340b37f8425ee3dea3e104727f456d53eb9f Log: Merge pull request #228 from mlex/master JENKINS-20392 Fix "Recent History" for merge jobs. Compare: https://github.com/jenkinsci/git-plugin/compare/f397b19b78f3...7b1f340b37f8
          Hide
          markewaite Mark Waite added a comment -

          Fixed in next release of git plugin - 2.2.5

          Show
          markewaite Mark Waite added a comment - Fixed in next release of git plugin - 2.2.5

            People

            • Assignee:
              ndeloof Nicolas De Loof
              Reporter:
              markewaite Mark Waite
            • Votes:
              4 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: