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

git pre-merge fails with matrix project

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      For a matrix project, the pre-merge occurs on the parent build, and the resulting merged revision number is passed to the slaves for their builds. However, the slaves are not able to checkout the merged revision because it only exists in the temporary parent clone. In the example below the build is triggered for revision d4c5faa85 on the feature branch xxx/xxx/develop. This feature branch is merged into xxx/master. This is the log for the parent build

      Fetching changes from the remote Git repository
      > git config remote.xxx.url ssh://repoURLremoved
      Pruning obsolete local branches
      Fetching upstream changes from ssh://repoURLremoved
      > git --version
      > git fetch --tags --progress ssh://repoURLremoved +refs/heads/:refs/remotes/xxx/ --prune
      > git rev-parse xxx/xxx/develop^

      {commit}
      Merging Revision d4c5faa8537180c26350fdecebe2d0b3d05c04c5 (xxx/xxx/develop) onto xxx/master using default strategy
      > git rev-parse xxx/master^{commit}

      > git config core.sparsecheckout
      > git checkout -f xxx/master
      > git merge d4c5faa8537180c26350fdecebe2d0b3d05c04c5
      > git rev-parse HEAD^

      {commit}

      Seen branch in repository xxx/xxx/develop
      Seen branch in repository xxx/master
      Seen 4 remote branches
      Checking out Revision 3ead3e08dc58524349b8c629a8a0a5775a3edf74 ()
      > git config core.sparsecheckout
      > git checkout -f 3ead3e08dc58524349b8c629a8a0a5775a3edf74
      ....

      Here is the log for one of the slaves

      Fetching changes from the remote Git repository
      > git config remote.xxx.url ssh://repoURLremoved
      Pruning obsolete local branches
      Fetching upstream changes from ssh://repoURLremoved
      > git --version
      > git fetch --tags --progress ssh://repoURLremoved +refs/heads/:refs/remotes/xxx/ --prune
      Checking out Revision 3ead3e08dc58524349b8c629a8a0a5775a3edf74 ()
      > git config core.sparsecheckout
      > git checkout -f 3ead3e08dc58524349b8c629a8a0a5775a3edf74
      FATAL: Could not checkout null with start point 3ead3e08dc58524349b8c629a8a0a5775a3edf74
      ....

      So the slave tries to checkout the temporary commit 3ead3e08d that only exists in the clone for the parent build.

      I've looked at the source and I think the problem is in the function determineRevisionToBuild in GitSCM.java. I am willing to spend some time on this, and I think I know how to solve the problem. However, I could use some guidance on testing to ensure I don't introduce a different bug in the process.

        Attachments

          Activity

          Hide
          galbramc Marshall Galbraith added a comment - - edited

          I created a unit test that reproduces the problem, and created a fix. Both are available with this pull request: https://github.com/jenkinsci/git-plugin/pull/235

          The fix does not modify the behavior for regular projects, or matrix projects that do not use the git pre-merge feature.

          The current implementation always uses the decorated revision for the matrix axes. However, the decorated revision only exists in the workspace of the cloned parent build, and does not exist in the cloned workspace for the axes. This fix causes the axes to use the marked revision, rather than the decorated one. The axes then subsequently decorate the marked revision.

          The only other way that I could think of fixing this problem would require the axes to pull the decorated revision from the parent workspace. However, this would cause all kinds of headaches in particular if working with multiple distributed slaves.

          Show
          galbramc Marshall Galbraith added a comment - - edited I created a unit test that reproduces the problem, and created a fix. Both are available with this pull request: https://github.com/jenkinsci/git-plugin/pull/235 The fix does not modify the behavior for regular projects, or matrix projects that do not use the git pre-merge feature. The current implementation always uses the decorated revision for the matrix axes. However, the decorated revision only exists in the workspace of the cloned parent build, and does not exist in the cloned workspace for the axes. This fix causes the axes to use the marked revision, rather than the decorated one. The axes then subsequently decorate the marked revision. The only other way that I could think of fixing this problem would require the axes to pull the decorated revision from the parent workspace. However, this would cause all kinds of headaches in particular if working with multiple distributed slaves.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Marshall Galbraith
          Path:
          src/test/java/hudson/plugins/git/AbstractGitTestCase.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/5bdffc3f1cea6836a108d1de618b70dbb1b0cb73
          Log:
          Created a unit test that reproduces JENKINS-23179

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marshall Galbraith Path: src/test/java/hudson/plugins/git/AbstractGitTestCase.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/5bdffc3f1cea6836a108d1de618b70dbb1b0cb73 Log: Created a unit test that reproduces JENKINS-23179
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Marshall Galbraith
          Path:
          src/main/java/hudson/plugins/git/GitSCM.java
          http://jenkins-ci.org/commit/git-plugin/288332ceae9a315140426334dd48907a12be2fdf
          Log:
          [FIXED JENKINS-23179] git pre-merge fails with matrix project

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marshall Galbraith Path: src/main/java/hudson/plugins/git/GitSCM.java http://jenkins-ci.org/commit/git-plugin/288332ceae9a315140426334dd48907a12be2fdf Log: [FIXED JENKINS-23179] git pre-merge fails with matrix project
          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/GitSCM.java
          src/test/java/hudson/plugins/git/AbstractGitTestCase.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/bbef8c089c75b074346748a0eb40dedbff5baad7
          Log:
          Merge pull request #235 from galbramc/master

          [FIXED JENKINS-23179] git pre-merge fails with matrix project

          Compare: https://github.com/jenkinsci/git-plugin/compare/e1ea04c8daca...bbef8c089c75

          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/GitSCM.java src/test/java/hudson/plugins/git/AbstractGitTestCase.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/bbef8c089c75b074346748a0eb40dedbff5baad7 Log: Merge pull request #235 from galbramc/master [FIXED JENKINS-23179] git pre-merge fails with matrix project Compare: https://github.com/jenkinsci/git-plugin/compare/e1ea04c8daca...bbef8c089c75
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Marshall Galbraith
          Path:
          src/test/java/hudson/plugins/git/AbstractGitTestCase.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/cecfd4f509ce2f678bf6ad844aa059b50d17e5eb
          Log:
          Created a unit test that reproduces JENKINS-23179

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marshall Galbraith Path: src/test/java/hudson/plugins/git/AbstractGitTestCase.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/cecfd4f509ce2f678bf6ad844aa059b50d17e5eb Log: Created a unit test that reproduces JENKINS-23179
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Marshall Galbraith
          Path:
          src/main/java/hudson/plugins/git/GitSCM.java
          http://jenkins-ci.org/commit/git-plugin/15f83d1386f6d54eaf6ed591c4cc787e36969ab8
          Log:
          [FIXED JENKINS-23179] git pre-merge fails with matrix project

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marshall Galbraith Path: src/main/java/hudson/plugins/git/GitSCM.java http://jenkins-ci.org/commit/git-plugin/15f83d1386f6d54eaf6ed591c4cc787e36969ab8 Log: [FIXED JENKINS-23179] git pre-merge fails with matrix project
          Hide
          markewaite Mark Waite added a comment -

          Will be available in the next git plugin release after 2.2.4 (probably 2.2.5).

          Show
          markewaite Mark Waite added a comment - Will be available in the next git plugin release after 2.2.4 (probably 2.2.5).
          Hide
          markewaite Mark Waite added a comment -

          Fixed in git client plugin 2.2.5, released 15 Aug 2014.

          Show
          markewaite Mark Waite added a comment - Fixed in git client plugin 2.2.5, released 15 Aug 2014.

            People

            • Assignee:
              ndeloof Nicolas De Loof
              Reporter:
              galbramc Marshall Galbraith
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: