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

NPE in BuildUser.makeUserBuildVariables()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: build-user-vars-plugin
    • Labels:
      None
    • Environment:
      Windows Server 2008, Oracle JDK 1.7.0_25-b16
      Jenkins LTS v1.554.1, Maven Integration Plugin v2.3, Subversion Plug-in v2.3
      build-user-vars-plugin-1.2 - 1.3
    • Similar Issues:

      Description

      After upgrading Jenkins and upgrading some plugins, I now get a NPEs in the log:

      maj 12, 2014 8:21:31 FM hudson.triggers.SCMTrigger$Runner runPolling
      SEVERE: Failed to record SCM polling for hudson.maven.MavenModuleSet@7987141d[jobname]
      java.lang.NullPointerException
      	at org.jenkinsci.plugins.builduser.BuildUser.makeUserBuildVariables(BuildUser.java:73)
      	at org.jenkinsci.plugins.builduser.BuildUser.makeUserBuildVariables(BuildUser.java:77)
      	at org.jenkinsci.plugins.builduser.BuildUser.makeBuildVariables(BuildUser.java:64)
      	at hudson.model.AbstractBuild.getBuildVariables(AbstractBuild.java:1043)
      	at hudson.scm.SubversionSCM.getLocations(SubversionSCM.java:520)
      	at hudson.scm.SubversionSCM.buildEnvVars(SubversionSCM.java:690)
      	at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:938)
      	at hudson.maven.AbstractMavenBuild.getEnvironment(AbstractMavenBuild.java:59)
      	at hudson.maven.MavenModuleSetBuild.getEnvironment(MavenModuleSetBuild.java:165)
      	at hudson.scm.SubversionSCM.compareRemoteRevisionWith(SubversionSCM.java:1392)
      	at hudson.scm.SCM._compareRemoteRevisionWith(SCM.java:356)
      	at hudson.scm.SCM.poll(SCM.java:373)
      	at hudson.model.AbstractProject._poll(AbstractProject.java:1584)
      	at hudson.model.AbstractProject.poll(AbstractProject.java:1493)
      	at hudson.triggers.SCMTrigger$Runner.runPolling(SCMTrigger.java:462)
      	at hudson.triggers.SCMTrigger$Runner.run(SCMTrigger.java:491)
      	at hudson.util.SequentialExecutionQueue$QueueEntry.run(SequentialExecutionQueue.java:118)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      	at java.util.concurrent.FutureTask.run(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at java.lang.Thread.run(Unknown Source)
      

        Attachments

          Activity

          Hide
          oleg_nenashev Oleg Nenashev added a comment -

          Hmm...
          The code is definitely invalid. There's no null check for "getBuildByNumber()", hence there will be a null recursion

          BuildUser.java:70
          70: private void makeUserBuildVariables(Run build, Map<String, String> variables) {
          71:
          72: // If build has been triggered form an upstream build, get UserCause from there to set user build variables
          73: Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) build.getCause(Cause.UpstreamCause.class);
          74: if (upstreamCause != null)

          Unknown macro: { 75}
          Show
          oleg_nenashev Oleg Nenashev added a comment - Hmm... The code is definitely invalid. There's no null check for "getBuildByNumber()", hence there will be a null recursion BuildUser.java:70 70: private void makeUserBuildVariables(Run build, Map<String, String> variables) { 71: 72: // If build has been triggered form an upstream build, get UserCause from there to set user build variables 73: Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) build.getCause(Cause.UpstreamCause.class); 74: if (upstreamCause != null) Unknown macro: { 75}
          Hide
          ahammar Anders Hammar added a comment -

          I did some investigation and here's the scenario for the exception:

          The latest build for the project 'jobname' was kicked off by a build in an usptream project. However, that build does no longer exist (it's been removed as there has been multiple builds after that) and hence we get a NPE.

          The strange thing is that there is no SCMTrigger.SCMTriggerCause in this execution, even though this exception is reported once per minute which maps to the checking in svn for changes (configured for this project).

          Show
          ahammar Anders Hammar added a comment - I did some investigation and here's the scenario for the exception: The latest build for the project 'jobname' was kicked off by a build in an usptream project. However, that build does no longer exist (it's been removed as there has been multiple builds after that) and hence we get a NPE. The strange thing is that there is no SCMTrigger.SCMTriggerCause in this execution, even though this exception is reported once per minute which maps to the checking in svn for changes (configured for this project).
          Show
          oleg_nenashev Oleg Nenashev added a comment - https://github.com/jenkinsci/build-user-vars-plugin/pull/4
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          src/test/java/org/jenkinsci/plugins/builduser/BuildUserTest.java
          http://jenkins-ci.org/commit/build-user-vars-plugin/6b1ac53e5bdabc00437ef10d35d7de74234b6074
          Log:
          JENKINS-22974 - Added a test case for the issue

          Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: src/test/java/org/jenkinsci/plugins/builduser/BuildUserTest.java http://jenkins-ci.org/commit/build-user-vars-plugin/6b1ac53e5bdabc00437ef10d35d7de74234b6074 Log: JENKINS-22974 - Added a test case for the issue Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          src/main/java/org/jenkinsci/plugins/builduser/BuildUser.java
          http://jenkins-ci.org/commit/build-user-vars-plugin/223500fbcb2da959efecc894bde3d0cd83417414
          Log:
          [FIXED JENKINS-22974] - Check for non-existent upstream builds

          Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: src/main/java/org/jenkinsci/plugins/builduser/BuildUser.java http://jenkins-ci.org/commit/build-user-vars-plugin/223500fbcb2da959efecc894bde3d0cd83417414 Log: [FIXED JENKINS-22974] - Check for non-existent upstream builds Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Clifford Sanders
          Path:
          src/main/java/org/jenkinsci/plugins/builduser/BuildUser.java
          src/test/java/org/jenkinsci/plugins/builduser/BuildUserTest.java
          http://jenkins-ci.org/commit/build-user-vars-plugin/5db4ca0edcc8c63862aaf366e9a64d148ba123a1
          Log:
          Merge pull request #4 from synopsys-arc-oss/JENKINS_22974_NPE_in_makeUserVars

          [FIXED JENKINS-22974] - NPE in makeUserVars if an upstream build is missing

          Compare: https://github.com/jenkinsci/build-user-vars-plugin/compare/da34a528af8e...5db4ca0edcc8

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Clifford Sanders Path: src/main/java/org/jenkinsci/plugins/builduser/BuildUser.java src/test/java/org/jenkinsci/plugins/builduser/BuildUserTest.java http://jenkins-ci.org/commit/build-user-vars-plugin/5db4ca0edcc8c63862aaf366e9a64d148ba123a1 Log: Merge pull request #4 from synopsys-arc-oss/JENKINS_22974_NPE_in_makeUserVars [FIXED JENKINS-22974] - NPE in makeUserVars if an upstream build is missing Compare: https://github.com/jenkinsci/build-user-vars-plugin/compare/da34a528af8e...5db4ca0edcc8

            People

            • Assignee:
              Unassigned
              Reporter:
              ahammar Anders Hammar
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: