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

Git plugin 2.0 JGit implementation does not publish merge result

    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

      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

        Attachments

          Issue Links

            Activity

            Hide
            kriskra Kristian Kraljic added a comment -

            Just one more thing. The JGitAPIImplTest.test_fetch_needs_preceding_prune test fails at line 1050:

            w.git.push("origin", "parent/a");
            

            I assumed that branches may not contain any "/". I fixed the fixRefSpec implementation.

            Show
            kriskra Kristian Kraljic added a comment - Just one more thing. The JGitAPIImplTest.test_fetch_needs_preceding_prune test fails at line 1050: w.git.push( "origin" , "parent/a" ); I assumed that branches may not contain any "/". I fixed the fixRefSpec implementation.
            Hide
            markewaite Mark Waite added a comment -

            An initial idea for the test is evolving as PushTest.java.

            It is currently missing tests for branches other than master and for branch names which contain embedded slashes. I'm confident there are many other relevant cases which it is missing. Could you review it and provide your feedback on GitHub?

            Show
            markewaite Mark Waite added a comment - An initial idea for the test is evolving as PushTest.java . It is currently missing tests for branches other than master and for branch names which contain embedded slashes. I'm confident there are many other relevant cases which it is missing. Could you review it and provide your feedback on GitHub?
            Hide
            kriskra Kristian Kraljic added a comment -

            Done so. Very nice test, I like it!

            Show
            kriskra Kristian Kraljic added a comment - Done so . Very nice test, I like it!
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Kristian Kraljic
            Path:
            src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java
            http://jenkins-ci.org/commit/git-client-plugin/c9e96d48062e6a8ed11857f0f00a00c86ec76c98
            Log:
            [Fix JENKINS-20393] Allow push for JGit repositories

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kristian Kraljic Path: src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java http://jenkins-ci.org/commit/git-client-plugin/c9e96d48062e6a8ed11857f0f00a00c86ec76c98 Log: [Fix JENKINS-20393] Allow push for JGit repositories
            Hide
            markewaite Mark Waite added a comment -

            Will be included in the next git client plugin after 1.18.0

            Show
            markewaite Mark Waite added a comment - Will be included in the next git client plugin after 1.18.0

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: