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

NPE on PreBuildMerge.decorateRevisionToBuild

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Trivial
    • Resolution: Fixed
    • git-plugin
    • None
    • core 1.642.4.2
      git:2.4.2 'Jenkins Git plugin'
      git-client:1.19.5 'Jenkins Git client plugin'
      Git for Windows 2.8.1
      Gitolite v3.6.3

    Description

      I detect that a return null form GitSCM.getBuildData is not checked into PreBuildMerge.decorateRevisionToBuild

       > C:\Git\bin\git.exe rev-parse "oppp/R362537^{commit}" # timeout=10
       > C:\Git\bin\git.exe config core.sparsecheckout # timeout=10
       > C:\Git\bin\git.exe checkout -f oppp/R362537
       > C:\Git\bin\git.exe merge --ff 6e11aa436022222222222229f13d9b13d73551b2 # timeout=10
       > C:\Git\bin\git.exe config core.sparsecheckout # timeout=10
       > C:\Git\bin\git.exe checkout -f 6e11aa4362222222222229b04f13d9b13d73551b2
      FATAL: null
      java.lang.NullPointerException
      	at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:88)
      	at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:965)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1054)
      	at hudson.scm.SCM.checkout(SCM.java:485)
      	at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
      	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
      	at hudson.model.Run.execute(Run.java:1738)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:410)
      Recording test results
      

      Attachments

        Issue Links

          Activity

            ifernandezcalvo Ivan Fernandez Calvo created issue -
            ifernandezcalvo Ivan Fernandez Calvo made changes -
            Field Original Value New Value
            Assignee Mark Waite [ markewaite ] Ivan Fernandez Calvo [ ifernandezcalvo ]

            I will make a pull request

                        BuildData bd = scm.getBuildData(build);
                        if(bd != null){
                            bd.saveBuild(new Build(marked,rev, build.getNumber(), FAILURE));
                        }
                        throw new AbortException("Branch not suitable for integration as it does not merge cleanly: " + ex.getMessage());
            
            ifernandezcalvo Ivan Fernandez Calvo added a comment - I will make a pull request BuildData bd = scm.getBuildData(build); if (bd != null ){ bd.saveBuild( new Build(marked,rev, build.getNumber(), FAILURE)); } throw new AbortException( "Branch not suitable for integration as it does not merge cleanly: " + ex.getMessage());
            ifernandezcalvo Ivan Fernandez Calvo made changes -
            Remote Link This issue links to "PR (Web Link)" [ 14228 ]
            ifernandezcalvo Ivan Fernandez Calvo made changes -
            Status Open [ 1 ] In Progress [ 3 ]

            Method GitSCM.getBuildData could return null

            public @CheckForNull BuildData getBuildData(Run build) { 
            

            but in PreBuildMerge.decorateRevisionToBuild does not check if a null is returned

            public Revision decorateRevisionToBuild(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision marked, Revision rev) throws IOException, InterruptedException {
            ...
                scm.getBuildData(build).saveBuild(new Build(marked,rev, build.getNumber(), FAILURE));
            
                throw new AbortException("Branch not suitable for integration as it does not merge cleanly: " + ex.getMessage());
            ...
            
            ifernandezcalvo Ivan Fernandez Calvo added a comment - Method GitSCM.getBuildData could return null public @CheckForNull BuildData getBuildData(Run build) { but in PreBuildMerge.decorateRevisionToBuild does not check if a null is returned public Revision decorateRevisionToBuild(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, Revision marked, Revision rev) throws IOException, InterruptedException { ... scm.getBuildData(build).saveBuild( new Build(marked,rev, build.getNumber(), FAILURE)); throw new AbortException( "Branch not suitable for integration as it does not merge cleanly: " + ex.getMessage()); ...

            I have seen this issue when using the git plugin to merge branches. Git needs to hit a merge conflict (or other error in merging maybe) to hit this problem.

            Without the pull request (git plugin 2.4.4)

             > git.exe merge --ff 4f7fc6bad3bc7778104b92950bfc1b3f5e1d3d9d # timeout=10
             > git.exe config core.sparsecheckout # timeout=10
             > git.exe checkout -f 4f7fc6bad3bc7778104b92950bfc1b3f5e1d3d9d
            FATAL: null
            java.lang.NullPointerException
            	at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:88)
            

            With the pull request applied on top of ce5479a42e74b45dd8b954776ad4220c9c0151bc the problem is reported better.

             > git.exe merge --ff 4f7fc6bad3bc7778104b92950bfc1b3f5e1d3d9d # timeout=10
             > git.exe config core.sparsecheckout # timeout=10
             > git.exe checkout -f 4f7fc6bad3bc7778104b92950bfc1b3f5e1d3d9d
            ERROR: Branch not suitable for integration as it does not merge cleanly: Could not merge AnyObjectId[4f7fc6bad3bc7778104b92950bfc1b3f5e1d3d9d]
            

            I think this should have a test case though.

            rg Russell Gallop added a comment - I have seen this issue when using the git plugin to merge branches. Git needs to hit a merge conflict (or other error in merging maybe) to hit this problem. Without the pull request (git plugin 2.4.4) > git.exe merge --ff 4f7fc6bad3bc7778104b92950bfc1b3f5e1d3d9d # timeout=10 > git.exe config core.sparsecheckout # timeout=10 > git.exe checkout -f 4f7fc6bad3bc7778104b92950bfc1b3f5e1d3d9d FATAL: null java.lang.NullPointerException at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:88) With the pull request applied on top of ce5479a42e74b45dd8b954776ad4220c9c0151bc the problem is reported better. > git.exe merge --ff 4f7fc6bad3bc7778104b92950bfc1b3f5e1d3d9d # timeout=10 > git.exe config core.sparsecheckout # timeout=10 > git.exe checkout -f 4f7fc6bad3bc7778104b92950bfc1b3f5e1d3d9d ERROR: Branch not suitable for integration as it does not merge cleanly: Could not merge AnyObjectId[4f7fc6bad3bc7778104b92950bfc1b3f5e1d3d9d] I think this should have a test case though.

            I'm seeing what seems to be the same issue, though if it's because of a merge conflict I can't see how. I've confirmed that the branches specified in the configuration ("Branch specifier" and "Branch to merge to") don't have any conflicts, making sure that the revision SHA of the former is what I expect it to be.

            My attempts are with mergeStrategy='default' and with fastForwardMode either '-ff' or '-no-ff'. Adding the behavior of "Wipe out repository & force clone" didn't help.

            Jenkins 1.656, git 2.4.1, git-client 1.19.6, github 1.19.1

            git rev-parse origin/source_branch^{commit} # timeout=10
            Merging Revision e9093107657cca2d27065f28ec39eec0edb94d51 (origin/source_branch) to origin/dest_branch, UserMergeOptions{mergeRemote='origin', mergeTarget='dest_branch', mergeStrategy='default', fastForwardMode='--ff'}
            git rev-parse origin/dest_branch^{commit} # timeout=10
            git config core.sparsecheckout # timeout=10
            git checkout -f origin/dest_branch
            git merge --ff e9093107657cca2d27065f28ec39eec0edb94d51 # timeout=10
            git config core.sparsecheckout # timeout=10
            git checkout -f e9093107657cca2d27065f28ec39eec0edb94d51
            FATAL: null
            java.lang.NullPointerException
            	at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:88)
            	at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:965)
            
            jamiemccarthy Jamie McCarthy added a comment - I'm seeing what seems to be the same issue, though if it's because of a merge conflict I can't see how. I've confirmed that the branches specified in the configuration ("Branch specifier" and "Branch to merge to") don't have any conflicts, making sure that the revision SHA of the former is what I expect it to be. My attempts are with mergeStrategy='default' and with fastForwardMode either '- ff' or ' -no-ff'. Adding the behavior of "Wipe out repository & force clone" didn't help. Jenkins 1.656, git 2.4.1, git-client 1.19.6, github 1.19.1 git rev-parse origin/source_branch^{commit} # timeout=10 Merging Revision e9093107657cca2d27065f28ec39eec0edb94d51 (origin/source_branch) to origin/dest_branch, UserMergeOptions{mergeRemote='origin', mergeTarget='dest_branch', mergeStrategy='default', fastForwardMode='--ff'} git rev-parse origin/dest_branch^{commit} # timeout=10 git config core.sparsecheckout # timeout=10 git checkout -f origin/dest_branch git merge --ff e9093107657cca2d27065f28ec39eec0edb94d51 # timeout=10 git config core.sparsecheckout # timeout=10 git checkout -f e9093107657cca2d27065f28ec39eec0edb94d51 FATAL: null java.lang.NullPointerException at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:88) at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:965)

            The pull request to resolve it is pending to approval

            https://github.com/jenkinsci/git-plugin/pull/394

            ifernandezcalvo Ivan Fernandez Calvo added a comment - The pull request to resolve it is pending to approval https://github.com/jenkinsci/git-plugin/pull/394
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 170469 ] JNJira + In-Review [ 185728 ]

            I encountered the same issue, with branches which merge works fine. I solved it by using JGit instead of Git Client

            geoffroya Geoffroy ARNOUD added a comment - I encountered the same issue, with branches which merge works fine. I solved it by using JGit instead of Git Client

            Code changed in jenkins
            User: Ivan Fernandez Calvo
            Path:
            src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java
            http://jenkins-ci.org/commit/git-plugin/11f792c756a6f030355df73932ccde99a9057146
            Log:
            JENKINS-34369 protect against a NPE form GitSCM.getBuildData is not checked into PreBuildMerge.decorateRevisionToBuild

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ivan Fernandez Calvo Path: src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java http://jenkins-ci.org/commit/git-plugin/11f792c756a6f030355df73932ccde99a9057146 Log: JENKINS-34369 protect against a NPE form GitSCM.getBuildData is not checked into PreBuildMerge.decorateRevisionToBuild

            Code changed in jenkins
            User: Mark Waite
            Path:
            src/main/java/hudson/plugins/git/extensions/impl/PreBuildMerge.java
            http://jenkins-ci.org/commit/git-plugin/2025127d7e82cc61b0b8f6ede91997c28bfd3c3d
            Log:
            Merge pull request #394 from kuisathaverat/JENKINS-34369

            JENKINS-34369 protect against a NPE form GitSCM.getBuildData

            Compare: https://github.com/jenkinsci/git-plugin/compare/fcbdc768536c...2025127d7e82

            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 http://jenkins-ci.org/commit/git-plugin/2025127d7e82cc61b0b8f6ede91997c28bfd3c3d Log: Merge pull request #394 from kuisathaverat/ JENKINS-34369 JENKINS-34369 protect against a NPE form GitSCM.getBuildData Compare: https://github.com/jenkinsci/git-plugin/compare/fcbdc768536c...2025127d7e82
            ifernandezcalvo Ivan Fernandez Calvo made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            ifernandezcalvo Ivan Fernandez Calvo made changes -
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Resolved [ 5 ]

            Ready for Release

            ifernandezcalvo Ivan Fernandez Calvo added a comment - Ready for Release
            markewaite Mark Waite added a comment -

            Released in git plugin 3.0.1, 18 Nov 2016

            markewaite Mark Waite added a comment - Released in git plugin 3.0.1, 18 Nov 2016
            markewaite Mark Waite made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

            People

              ifernandezcalvo Ivan Fernandez Calvo
              ifernandezcalvo Ivan Fernandez Calvo
              Votes:
              4 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: