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

xUnit throws NPE when no threshold was specified

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      After upgrading the xunit plugin from version 1.102 to 1.103, my build started failing at the following line in the jenkinsfile/pipeline.

      step([$class: 'XUnitBuilder', tools: [[$class: 'XUnitDotNetTestType', pattern: '*results.xml']]])

      It throws the following exception.

      java.lang.NullPointerException
      at org.jenkinsci.plugins.xunit.XUnitBuilder.<init>(XUnitBuilder.java:65)
      at org.jenkinsci.plugins.xunit.XUnitBuilder.<init>(XUnitBuilder.java:71)
      Caused: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:282)
      Caused: java.lang.IllegalArgumentException: Could not instantiate {tools=[{$class=XUnitDotNetTestType}]} for XUnitBuilder(tools: TestType{AUnitJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | BoostTestJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | CTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | CUnitJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | CheckType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | CppTestJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | CppUnitJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | CustomType(pattern: String, customXSL: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | EmbUnitType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | FPCUnitJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | GTesterJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | GoogleTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | JUnitType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | MSTestJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | MbUnitType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | NUnitJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | PHPUnitJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | QTestLibType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | UnitTestJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | ValgrindJunitHudsonTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean) | XUnitDotNetTestType(pattern: String, skipNoTestFiles: boolean, failIfNotNew: boolean, deleteOutputFiles: boolean, stopProcessingIfError: boolean)}[], thresholds: XUnitThreshold{FailedThreshold(unstableThreshold: String, unstableNewThreshold: String, failureThreshold: String, failureNewThreshold: String) | SkippedThreshold(unstableThreshold: String, unstableNewThreshold: String, failureThreshold: String, failureNewThreshold: String)}[], thresholdMode: int, testTimeMargin: String)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:286)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:402)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:340)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:281)
      at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:201)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:208)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:153)
      at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
      at sun.reflect.GeneratedMethodAccessor527.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)
      at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:133)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)
      at .....
      Finished: FAILURE
      

      The following command works though.

      step([$class: 'XUnitBuilder', thresholds: [[$class: 'FailedThreshold', unstableThreshold: '1']], tools: [[$class: 'XUnitDotNetTestType', pattern: '*results.xml']]])

      Please let me know if you need any additional information.

        Attachments

          Activity

          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Nikolas Falco
          Path:
          src/main/java/org/jenkinsci/plugins/xunit/XUnitBuilder.java
          src/main/java/org/jenkinsci/plugins/xunit/XUnitPublisher.java
          src/test/java/org/jenkinsci/plugins/xunit/XUnitWorkflowTest.java
          http://jenkins-ci.org/commit/xunit-plugin/875dc671cc49b7981a7b9dfb2a7aa99e5d3504df
          Log:
          JENKINS-51056 xUnit throws NPE when no threshold was specified

          Add check for null in builder and publisher constructors when tools and thresholds are not defined.

          *NOTE:* This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

          Functionality will be removed from GitHub.com on January 31st, 2019.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nikolas Falco Path: src/main/java/org/jenkinsci/plugins/xunit/XUnitBuilder.java src/main/java/org/jenkinsci/plugins/xunit/XUnitPublisher.java src/test/java/org/jenkinsci/plugins/xunit/XUnitWorkflowTest.java http://jenkins-ci.org/commit/xunit-plugin/875dc671cc49b7981a7b9dfb2a7aa99e5d3504df Log: JENKINS-51056 xUnit throws NPE when no threshold was specified Add check for null in builder and publisher constructors when tools and thresholds are not defined. * NOTE: * This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/ Functionality will be removed from GitHub.com on January 31st, 2019.
          Hide
          nfalco Nikolas Falco added a comment - - edited

          In the standard build step thresholds are always defined also if without values. It's true that in the pipeline you can around these kind of constraints. Anyway I test your pipeline and it fails because thresholdMode is required, it can not be defaulted to nul (it is int). Are you sure the pipeline you post is correct?

          I will add check for null to avoid NPE.

          Show
          nfalco Nikolas Falco added a comment - - edited In the standard build step thresholds are always defined also if without values. It's true that in the pipeline you can around these kind of constraints. Anyway I test your pipeline and it fails because thresholdMode is required, it can not be defaulted to nul (it is int). Are you sure the pipeline you post is correct? I will add check for null to avoid NPE.

            People

            • Assignee:
              nfalco Nikolas Falco
              Reporter:
              ryangates Ryan Gates
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: