Jenkins: XUnitPublisher aborted due to exception. The types section is required.

Jenkins is an extendable open source continuous integration (CI) server, developed by Sun Microsystems and also known as the former Hudson project. A CI toolchain helps you automate repetitive tasks such as compiling your software, executing test runners and emailing you reports.

Jenkins is using XML to describe what a specific task should look like. In order to run your unit tests the xunit plugin integrates a unit testing framework, e.g. PHPUnit, with your CI environment. Sometimes the plugin fails to save its settings correctly and you’ll get the XUnitPublisher aborting due to missing type definitions.

ERROR: Publisher org.jenkinsci.plugins.xunit.XUnitPublisher aborted due to exception
java.lang.NullPointerException: The types section is required.
    at org.jenkinsci.plugins.xunit.XUnitProcessor.(XUnitProcessor.java:65)
    at org.jenkinsci.plugins.xunit.XUnitPublisher.perform(XUnitPublisher.java:111)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
    at hudson.model.Build$BuildExecution.post2(Build.java:183)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
    at hudson.model.Run.execute(Run.java:1770)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:89)
    at hudson.model.Executor.run(Executor.java:240)
Finished: FAILURE

The above error message clearly says that in your /var/lib/jenkins/jobs/your-actual-job/config.xml the types section is missing and Jenkins is right. Open this file and go to the publishers section, here you add the types section, as highlighted in the code example below, as a child to the XML node xunit.

<project>
  ...
  <publishers>
    <xunit plugin="xunit@1.91">
      
      <types>
        <PHPUnitJunitHudsonTestType>
          <pattern>build/reports/**/*.xml</pattern>
          <skipNoTestFiles>false</skipNoTestFiles>
          <failIfNotNew>true</failIfNotNew>
          <deleteOutputFiles>true</deleteOutputFiles>
          <stopProcessingIfError>true</stopProcessingIfError>
        </PHPUnitJunitHudsonTestType>
      </types>
      
      <thresholds>
        <org.jenkinsci.plugins.xunit.threshold.FailedThreshold>
          <unstableThreshold>200</unstableThreshold>
          <unstableNewThreshold>200</unstableNewThreshold>
          <failureThreshold>0</failureThreshold>
          <failureNewThreshold>0</failureNewThreshold>
        </org.jenkinsci.plugins.xunit.threshold.FailedThreshold>
        <org.jenkinsci.plugins.xunit.threshold.SkippedThreshold>
          <unstableThreshold>200</unstableThreshold>
          <unstableNewThreshold>200</unstableNewThreshold>
          <failureThreshold>0</failureThreshold>
          <failureNewThreshold>0</failureNewThreshold>
        </org.jenkinsci.plugins.xunit.threshold.SkippedThreshold>
      </thresholds>
      <thresholdMode>1</thresholdMode>
      <extraConfiguration>
        <testTimeMargin>10000</testTimeMargin>
      </extraConfiguration>
    </xunit>
  </publishers>
  ...
</project>

If you use another testing framework than PHPUnit click here to find more about the supported types or try one of the following list.

  • AUnitJunitHudsonTestType
  • BoostTestJunitHudsonTestType
  • CTestType
  • CppTestJunitHudsonTestType
  • CppUnitJunitHudsonTestType
  • JUnitType
  • NUnitJunitHudsonTestType
  • PHPUnitJunitHudsonTestType

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>