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

Git plugin 2.0 JGit implementation does not publish merge result

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Jenkins 1.509.4, Git plugin 2.0, Git client plugin 1.4.6, Debian Linux 7.2 ("Wheezy"), JDK 1.7.0u45 x64

      If I use the jgit implementation in a job which should merge from multiple branches, the merge result is not pushed back to origin. Merge result is pushed if I use the command line implementation in the same job.

      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. Use jgit rather than default
          2. Repository URL: /tmp/changes.git
          3. 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
      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
      6. Confirm master branch did not receive the merge result
        1. git checkout master
        2. git pull
        3. git log

          [JENKINS-20393] Git plugin 2.0 JGit implementation does not publish merge result

          Mark Waite created issue -
          Mark Waite made changes -
          Description Original: 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)

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

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

          # Create a bare git repo on the master node as Jenkins user
          ## {{rm -rf /tmp/changes.git /tmp/changes}}
          ## {{git init --bare /tmp/changes.git}}
          ## {{echo "#! /bin/sh" > /tmp/changes.git/hooks/post-receive}}
          ## echo "curl --silent http://127.0.0.1:8080/git/notifyCommit?url=/tmp/changes.git\" >> /tmp/changes.git/hooks/post-receive
          ## {{chmod a+x /tmp/changes.git/hooks/post-receive}}
          ## {{cd /tmp}}
          ## {{git clone changes.git}}
          ## {{cd changes}}
          ## {{echo "Git plugin 2.0 no longer shows changes from merges" > README}}
          ## {{git add README}}
          ## {{git commit -m "Add README to describe this repository" README}}
          ## {{git push origin master}}
          # Create a Jenkins merge job using that bare git repo
          ## Create a new free-style software project "merge-changes"
          ## Restrict where this project can be run
          ### Label Expression: master
          ## Git source code management settings
          ### Use jgit rather than default
          ### Repository URL: /tmp/changes.git
          ### Branches to build: \*/master\*
          ## Additional behaviors: Merge before build
          ### Name of repository: origin
          #### (error on merge if this is blank - help says should use default, but didn't)
          ### Branch to merge to: master
          ## Poll SCM (for convenience with the git hook installed earlier)
          ### H * * * *
          ## Add post-build action: Git Publisher
          ### Git Publisher settings
          #### Merge results: Yes
          #### Branches:
          ##### Branches to push: master
          ##### Target remote name: origin
          ## Save the job
          # Build Jenkins job
          ## curl --silent http://127.0.0.1:8080/job/merge-changes/build?delay=0sec
          # Create new master-add-timestamp branch and commit from it
          ## {{git checkout -b master-add-timestamp}}
          ## {{date >> timestamp}}
          ## {{git add timestamp}}
          ## {{git commit -m "Add timestamp" timestamp}}
          ## {{git push origin master-add-timestamp}}
          # Jenkins job runs
          # Confirm master branch did not receive the merge result
          ## {{git checkout master}}
          ## {{git pull}}
          ## {{git log}}
          Mark Waite made changes -
          Description Original: If I use the jgit implementation in a job which should merge from multiple branches, the merge result is not pushed back to origin. Merge result is pushed if I use the command line implementation in the same job.

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

          # Create a bare git repo on the master node as Jenkins user
          ## {{rm -rf /tmp/changes.git /tmp/changes}}
          ## {{git init --bare /tmp/changes.git}}
          ## {{echo "#! /bin/sh" > /tmp/changes.git/hooks/post-receive}}
          ## echo "curl --silent http://127.0.0.1:8080/git/notifyCommit?url=/tmp/changes.git\" >> /tmp/changes.git/hooks/post-receive
          ## {{chmod a+x /tmp/changes.git/hooks/post-receive}}
          ## {{cd /tmp}}
          ## {{git clone changes.git}}
          ## {{cd changes}}
          ## {{echo "Git plugin 2.0 no longer shows changes from merges" > README}}
          ## {{git add README}}
          ## {{git commit -m "Add README to describe this repository" README}}
          ## {{git push origin master}}
          # Create a Jenkins merge job using that bare git repo
          ## Create a new free-style software project "merge-changes"
          ## Restrict where this project can be run
          ### Label Expression: master
          ## Git source code management settings
          ### Use jgit rather than default
          ### Repository URL: /tmp/changes.git
          ### Branches to build: \*/master\*
          ## Additional behaviors: Merge before build
          ### Name of repository: origin
          #### (error on merge if this is blank - help says should use default, but didn't)
          ### Branch to merge to: master
          ## Poll SCM (for convenience with the git hook installed earlier)
          ### H * * * *
          ## Add post-build action: Git Publisher
          ### Git Publisher settings
          #### Merge results: Yes
          #### Branches:
          ##### Branches to push: master
          ##### Target remote name: origin
          ## Save the job
          # Build Jenkins job
          ## curl --silent http://127.0.0.1:8080/job/merge-changes/build?delay=0sec
          # Create new master-add-timestamp branch and commit from it
          ## {{git checkout -b master-add-timestamp}}
          ## {{date >> timestamp}}
          ## {{git add timestamp}}
          ## {{git commit -m "Add timestamp" timestamp}}
          ## {{git push origin master-add-timestamp}}
          # Jenkins job runs
          # Confirm master branch did not receive the merge result
          ## {{git checkout master}}
          ## {{git pull}}
          ## {{git log}}
          New: If I use the jgit implementation in a job which should merge from multiple branches, the merge result is not pushed back to origin. Merge result is pushed if I use the command line implementation in the same job.

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

          # Create a bare git repo on the master node as Jenkins user
          ## {{rm -rf /tmp/changes.git /tmp/changes}}
          ## {{git init --bare /tmp/changes.git}}
          ## {{echo "#! /bin/sh" > /tmp/changes.git/hooks/post-receive}}
          ## echo "curl --silent http://127.0.0.1:8080/git/notifyCommit?url=/tmp/changes.git" >> /tmp/changes.git/hooks/post-receive
          ## {{chmod a+x /tmp/changes.git/hooks/post-receive}}
          ## {{cd /tmp}}
          ## {{git clone changes.git}}
          ## {{cd changes}}
          ## {{echo "Git plugin 2.0 no longer shows changes from merges" > README}}
          ## {{git add README}}
          ## {{git commit -m "Add README to describe this repository" README}}
          ## {{git push origin master}}
          # Create a Jenkins merge job using that bare git repo
          ## Create a new free-style software project "merge-changes"
          ## Restrict where this project can be run
          ### Label Expression: master
          ## Git source code management settings
          ### Use jgit rather than default
          ### Repository URL: /tmp/changes.git
          ### Branches to build: \*/master\*
          ## Additional behaviors: Merge before build
          ### Name of repository: origin
          #### (error on merge if this is blank - help says should use default, but didn't)
          ### Branch to merge to: master
          ## Poll SCM (for convenience with the git hook installed earlier)
          ### H * * * *
          ## Add post-build action: Git Publisher
          ### Git Publisher settings
          #### Merge results: Yes
          #### Branches:
          ##### Branches to push: master
          ##### Target remote name: origin
          ## Save the job
          # Build Jenkins job
          ## curl --silent http://127.0.0.1:8080/job/merge-changes/build?delay=0sec
          # Create new master-add-timestamp branch and commit from it
          ## {{git checkout -b master-add-timestamp}}
          ## {{date >> timestamp}}
          ## {{git add timestamp}}
          ## {{git commit -m "Add timestamp" timestamp}}
          ## {{git push origin master-add-timestamp}}
          # Jenkins job runs
          # Confirm master branch did not receive the merge result
          ## {{git checkout master}}
          ## {{git pull}}
          ## {{git log}}

          Mark Waite added a comment -

          Confirmed still an issue with git client plugin 1.10.1 and git plugin 2.2.4.

          Mark Waite added a comment - Confirmed still an issue with git client plugin 1.10.1 and git plugin 2.2.4.
          Mark Waite made changes -
          Link New: This issue is duplicated by JENKINS-25797 [ JENKINS-25797 ]
          Mark Waite made changes -
          Assignee Original: Nicolas De Loof [ ndeloof ]
          Mark Waite made changes -
          Link New: This issue is duplicated by JENKINS-29271 [ JENKINS-29271 ]

          Kristian Kraljic added a comment - - edited

          Hello Mark,

          Is there any workaround available? Or have you been able to locate the root cause? Is there anything I can help you with fixing? JENKINS-29271 is affecting a productive scenario in our case, so I am very interested in a fix.

          Thanks & regards, Kristian

          Kristian Kraljic added a comment - - edited Hello Mark, Is there any workaround available? Or have you been able to locate the root cause? Is there anything I can help you with fixing? JENKINS-29271 is affecting a productive scenario in our case, so I am very interested in a fix. Thanks & regards, Kristian

          Mark Waite added a comment -

          One work around is to use command line git instead of JGit.

          I don't know the root cause, since job gives the usual log information which would indicate it was pushing using JGit (at least in my case), but the changes never appear in the remote repository.

          You could also download the git client plugin source code, write a test which shows the problem, then write the code to fix the test, and submit that as a pull request. That area of the code is unfamiliar to me. It appears to temporarily configure a remote, then uses that temporarily configured remote to push the changes, then removes the definition of that remote. I assume that was simpler to implement than deducing the name of the remote which was used to clone the workspace.

          Mark Waite added a comment - One work around is to use command line git instead of JGit. I don't know the root cause, since job gives the usual log information which would indicate it was pushing using JGit (at least in my case), but the changes never appear in the remote repository. You could also download the git client plugin source code , write a test which shows the problem, then write the code to fix the test, and submit that as a pull request. That area of the code is unfamiliar to me. It appears to temporarily configure a remote, then uses that temporarily configured remote to push the changes, then removes the definition of that remote. I assume that was simpler to implement than deducing the name of the remote which was used to clone the workspace.

          Hey Mark, just to clarify. A while back you stated in JENKINS-25797 that JGitAPIImpl is lacking a push implementation that canbe used by GitPublisher. Could this still be the case and the cause of the problem? I hadn't had the chance to check the JGitAPIImpl implementation yet, what do you think?

          Kristian Kraljic added a comment - Hey Mark, just to clarify. A while back you stated in JENKINS-25797 that JGitAPIImpl is lacking a push implementation that canbe used by GitPublisher. Could this still be the case and the cause of the problem? I hadn't had the chance to check the JGitAPIImpl implementation yet, what do you think?

            Unassigned Unassigned
            markewaite Mark Waite
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: