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

NullPointerException using project-stats-plugin

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: project-stats-plugin
    • Labels:
      None
    • Environment:
      Jenkins 1.478 - Project statistics Plugin 0.3
    • Similar Issues:

      Description

      NullPointerException using Project Stats plugin in Jenkins :
      Stack trace :
      java.lang.NullPointerException
      at hudson.plugins.projectstats.NumBuildsStats.compute(NumBuildsStats.java:51)
      at hudson.plugins.projectstats.column.NumBuildsColumn.getStats(NumBuildsColumn.java:53)
      at sun.reflect.GeneratedMethodAccessor137.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
      at java.lang.reflect.Method.invoke(Method.java:611)
      at org.apache.commons.jexl.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:258)
      at org.apache.commons.jexl.parser.ASTMethod.execute(ASTMethod.java:104)
      at org.apache.commons.jexl.parser.ASTReference.execute(ASTReference.java:83)
      at org.apache.commons.jexl.parser.ASTReference.value(ASTReference.java:57)
      at org.apache.commons.jexl.parser.ASTReferenceExpression.value(ASTReferenceExpression.java:51)
      at org.apache.commons.jexl.ExpressionImpl.evaluate(ExpressionImpl.java:73)
      at hudson.ExpressionFactory2$JexlExpression.evaluate(ExpressionFactory2.java:72)
      at org.apache.commons.jelly.tags.core.CoreTagLibrary$3.run(CoreTagLibrary.java:134)
      at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
      at org.kohsuke.stapler.jelly.JellyViewScript.run(JellyViewScript.java:81)
      at org.kohsuke.stapler.jelly.IncludeTag.doTag(IncludeTag.java:99)
      at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
      at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
      ...

      Error occured in this method :

      public void compute(Job job) {
      List<Run> builds = job.getBuilds();
      for (Run build : builds)

      { if (build.getResult().isBetterOrEqualTo(Result.SUCCESS)) addSuccess(); else if (build.getResult().isBetterOrEqualTo(Result.UNSTABLE)) addUnstable(); else if (build.getResult().isBetterOrEqualTo(Result.FAILURE)) addFail(); }

      }

      build.getResult() seems to be null.
      I've made a groovy script to find job where a build can have a null result :

      Jenkins.instance.items.findAll

      {job -> job.isBuildable()}

      .each{ Job job ->
      if(job.getBuilds() != null) {
      for (Run build : job.getBuilds()) {
      if(build.getResult() == null)

      { println "('"+build.number+"') null : " + job.name }

      }
      }
      }

      All resulting jobs are currently building.

      It seems that the plugin don't check if the job is currently building, that result in a NullPointerException here.

      Michaƫl

        Attachments

          Issue Links

            Activity

            Hide
            koconnor Kyle O'Connor added a comment -

            I can confirm that the problem exists in the latest version of project-stats-plugin because it does not check if the job is currently building before trying to access number of build results.

            Show
            koconnor Kyle O'Connor added a comment - I can confirm that the problem exists in the latest version of project-stats-plugin because it does not check if the job is currently building before trying to access number of build results.
            Hide
            mpapo Michael Pailloncy added a comment -

            A pull-request to resolve the issue is opened : https://github.com/jenkinsci/project-stats-plugin/pull/2

            Show
            mpapo Michael Pailloncy added a comment - A pull-request to resolve the issue is opened : https://github.com/jenkinsci/project-stats-plugin/pull/2
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Michael Pailloncy
            Path:
            src/main/java/hudson/plugins/projectstats/NumBuildsStats.java
            http://jenkins-ci.org/commit/project-stats-plugin/1debd0583b734074822228a34c7fea1555119c2e
            Log:
            FIX JENKINS-15067 : a build result can be null if the build is currently building.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Michael Pailloncy Path: src/main/java/hudson/plugins/projectstats/NumBuildsStats.java http://jenkins-ci.org/commit/project-stats-plugin/1debd0583b734074822228a34c7fea1555119c2e Log: FIX JENKINS-15067 : a build result can be null if the build is currently building.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Marco Ambu
            Path:
            src/main/java/hudson/plugins/projectstats/NumBuildsStats.java
            http://jenkins-ci.org/commit/project-stats-plugin/63c3393e9c4d3763432358ceee865a52651efb7b
            Log:
            Merge pull request #2 from mpapo/JENKINS-15067

            FIX JENKINS-15067 : a build result can be null if the build is currently...

            Compare: https://github.com/jenkinsci/project-stats-plugin/compare/d31ab5bb2d09...63c3393e9c4d

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marco Ambu Path: src/main/java/hudson/plugins/projectstats/NumBuildsStats.java http://jenkins-ci.org/commit/project-stats-plugin/63c3393e9c4d3763432358ceee865a52651efb7b Log: Merge pull request #2 from mpapo/ JENKINS-15067 FIX JENKINS-15067 : a build result can be null if the build is currently... Compare: https://github.com/jenkinsci/project-stats-plugin/compare/d31ab5bb2d09...63c3393e9c4d
            Show
            mpapo Michael Pailloncy added a comment - https://github.com/jenkinsci/project-stats-plugin/commit/63c3393e9c4d3763432358ceee865a52651efb7b seems to have corrected the problem.

              People

              • Assignee:
                mpapo Michael Pailloncy
                Reporter:
                mpapo Michael Pailloncy
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: