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

Checkstyle plugin doesn't fail build when xml parsing fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • checkstyle-plugin
    • None

      Recently we had a case where a linter was outputting poorly formatted xml. The checkstyle publisher would recognize this with the following error:

      Errors

      Module : Parsing of file /home/auto/workspace/sox-sniff.xml failed due to an exception: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 1; Content is not allowed in prolog. at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.commons.digester3.Digester.parse(Digester.java:1642) at org.apache.commons.digester3.Digester.parse(Digester.java:1745) at hudson.plugins.checkstyle.parser.CheckStyleParser.parse(CheckStyleParser.java:67) at hudson.plugins.analysis.core.AbstractAnnotationParser.parse(AbstractAnnotationParser.java:54) at hudson.plugins.analysis.core.FilesParser.parseFile(FilesParser.java:324) at hudson.plugins.analysis.core.FilesParser.parseFiles(FilesParser.java:282) at hudson.plugins.analysis.core.FilesParser.parserCollectionOfFiles(FilesParser.java:233) at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:202) at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:32) at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2691) at hudson.remoting.UserRequest.perform(UserRequest.java:120) at hudson.remoting.UserRequest.perform(UserRequest.java:48) at hudson.remoting.Request$2.run(Request.java:326) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)

      However, the build would succeed!

      I am able to reproduce with plugin version 3.44 and a simple freestyle job with the following shell:

      cat << EOF > checkstyle.xml
      SOME GARBAGE ABOVE THE PROLOG
      <checkstyle version="1.4.3">
      </checkstyle>
      EOF

      my current workaround is to add this to the shell after the checkstyle is created:

      xmllint checkstyle.xml

            drulli Ulli Hafner
            jimbo jim gedarovich
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: