我在我的 Jenkins 服务器中使用静态分析工具 checkstyle 在构建后对私有 maven 项目运行静态分析。我已经在 Jenkins 的 Post Build 设置中完成了配置。
有一个格式正确的 checkstyle 配置文件,名为csc_checkstyle.xml,它在 Jenkins 的 Post-Build 部分中设置 我们已将 checkstyle 插件和下一代警告添加到 Jenkins。checkstyle 配置文件设置正确。
当构建运行并触发此插件时,我们会收到以下错误:
[CheckStyle] [ERROR] Parsing of file '/var/lib/jenkins/workspace/iTrust/iTrust2/src/test/resources/reporting/csc_checkstyle.xml' failed due to an exception:
[CheckStyle] [ERROR] java.lang.NullPointerException
[CheckStyle] [ERROR] [wrapped] java.net.MalformedURLException
[CheckStyle] [ERROR] at java.net.URL.(URL.java:627)
[CheckStyle] [ERROR] at java.net.URL.(URL.java:490)
[CheckStyle] [ERROR] at java.net.URL.(URL.java:439)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:620)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1304)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1270)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:264)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1161)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1045)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:959)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
[CheckStyle] [ERROR] at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
[CheckStyle] [ERROR] at org.apache.commons.digester3.Digester.parse(Digester.java:1642)
[CheckStyle] [ERROR] at org.apache.commons.digester3.Digester.parse(Digester.java:1745)
[CheckStyle] [ERROR] at edu.hm.hafner.analysis.parser.checkstyle.CheckStyleParser.parse(CheckStyleParser.java:47)
[CheckStyle] [ERROR] [wrapped] edu.hm.hafner.analysis.ParsingException: Exception occurred during parsing: null
[CheckStyle] [ERROR] at edu.hm.hafner.analysis.parser.checkstyle.CheckStyleParser.parse(CheckStyleParser.java:55)
[CheckStyle] [ERROR] at io.jenkins.plugins.analysis.core.model.FilesScanner.aggregateIssuesOfFile(FilesScanner.java:98)
[CheckStyle] [ERROR] at io.jenkins.plugins.analysis.core.model.FilesScanner.scanFiles(FilesScanner.java:82)
[CheckStyle] [ERROR] at io.jenkins.plugins.analysis.core.model.FilesScanner.invoke(FilesScanner.java:65)
[CheckStyle] [ERROR] at io.jenkins.plugins.analysis.core.model.FilesScanner.invoke(FilesScanner.java:28)
[CheckStyle] [ERROR] at hudson.FilePath.act(FilePath.java:1078)
[CheckStyle] [ERROR] at hudson.FilePath.act(FilePath.java:1061)
[CheckStyle] [ERROR] at io.jenkins.plugins.analysis.core.model.ReportScanningTool.scanInWorkspace(ReportScanningTool.java:126)
[CheckStyle] [ERROR] at io.jenkins.plugins.analysis.core.model.ReportScanningTool.scan(ReportScanningTool.java:108)
[CheckStyle] [ERROR] at io.jenkins.plugins.analysis.core.steps.IssuesScanner.scan(IssuesScanner.java:66)
[CheckStyle] [ERROR] at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.scanWithTool(IssuesRecorder.java:578)
[CheckStyle] [ERROR] at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.record(IssuesRecorder.java:546)
[CheckStyle] [ERROR] at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.perform(IssuesRecorder.java:514)
[CheckStyle] [ERROR] at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
[CheckStyle] [ERROR] at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
[CheckStyle] [ERROR] at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
[CheckStyle] [ERROR] at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
[CheckStyle] [ERROR] at hudson.model.Build$BuildExecution.post2(Build.java:186)
[CheckStyle] [ERROR] at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
[CheckStyle] [ERROR] at hudson.model.Run.execute(Run.java:1835)
[CheckStyle] [ERROR] at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
[CheckStyle] [ERROR] at hudson.model.ResourceController.execute(ResourceController.java:97)
[CheckStyle] [ERROR] at hudson.model.Executor.run(Executor.java:429)
这里要注意的是,配置文件的路径/var/lib/jenkins/workspace/iTrust/iTrust2/src/test/resources/reporting/csc_checkstyle.xml
是正确的。
有谁知道为什么NullPointerException
会抛出 a ?文件的格式似乎也正确。
这csc_checkstyle.xml
是Google 默认 checkstyle 配置的原始版本