在ANT构建脚本中使用Jenkins和PHP Code Sniffer

时间:2014-06-19 12:55:35

标签: php ant jenkins checkstyle codesniffer

我在Jenkins中使用PHP Code Sniffer插件。 它生成一个checkstyle.xml文件,但jenkins服务器无法解析文件

我在Build Console Output中获得以下内容。

phpdox:
...
[exec]     Parsing checkstyle logfile failed: loading file 'logs/checkstyle.xml' failed.
[exec] [/var/lib/jenkins/jobs/AtomFrontEnd-Master/workspace/build/logs/checkstyle.xml] [Line: 345 - Column: 1] Fatal Error 5: Extra content at the end of the document
...

build:

Total time: 3 minutes 32 seconds
[CHECKSTYLE] Collecting checkstyle analysis files...
[CHECKSTYLE] Finding all files that match the pattern build/logs/checkstyle.xml
[CHECKSTYLE] Parsing 1 files in /var/lib/jenkins/jobs/AtomFrontEnd-Master/workspace
[CHECKSTYLE] Parsing of file /var/lib/jenkins/jobs/AtomFrontEnd-Master/workspace/build/logs/checkstyle.xml failed due to an exception:

org.xml.sax.SAXParseException; lineNumber: 345; columnNumber: 2; The markup in the document following the root element must be well-formed.
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1239)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
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:53)
at hudson.plugins.analysis.core.FilesParser.parseFile(FilesParser.java:300)
at hudson.plugins.analysis.core.FilesParser.parseFiles(FilesParser.java:258)
at hudson.plugins.analysis.core.FilesParser.parserCollectionOfFiles(FilesParser.java:209)
at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:178)
at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:31)
at hudson.FilePath.act(FilePath.java:920)
at hudson.FilePath.act(FilePath.java:893)
at hudson.plugins.checkstyle.CheckStylePublisher.perform(CheckStylePublisher.java:143)
at hudson.plugins.analysis.core.HealthAwarePublisher.perform(HealthAwarePublisher.java:144)
at hudson.plugins.analysis.core.HealthAwareRecorder.perform(HealthAwareRecorder.java:333)
at hudson.tasks.BuildStepMonitor$2.perform(BuildStepMonitor.java:32)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:772)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:736)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:685)
at hudson.model.Run.execute(Run.java:1757)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)


...
ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception
java.io.IOException: Expecting tag checkstyle
at hudson.plugins.violations.parse.AbstractParser.expectNextTag(AbstractParser.java:268)
at hudson.plugins.violations.types.checkstyle.CheckstyleParser.execute(CheckstyleParser.java:39)
at hudson.plugins.violations.parse.AbstractTypeParser.parse(AbstractTypeParser.java:57)
at hudson.plugins.violations.ViolationsCollector.doType(ViolationsCollector.java:187)
at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:114)
at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:25)
at hudson.FilePath.act(FilePath.java:920)
at hudson.FilePath.act(FilePath.java:893)
at hudson.plugins.violations.ViolationsPublisher.perform(ViolationsPublisher.java:74)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:772)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:736)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:685)
at hudson.model.Run.execute(Run.java:1757)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)

此服务器正在运行CentOS 6.5 PHP版本:5.4.29 Apache Ant版本1.9.4

checkstyle.xml文件以标记

开头
<file ... >
    ...
</file>

当我使用相同的Ant版本从Ubuntu运行相同的Ant构建脚本时,我的checkstyle.xml文件看起来像这样

<?xml version="1.0" encoding="UTF-8"?>
   <checkstyle version="2.0.0a2">
      <file ... >
         ...
      </file>
   </checkstyle>

1 个答案:

答案 0 :(得分:0)

我有同样的问题,当我在Ant中打开输出时,我发现phpcs内存不足。在我增加了php.ini中的memory_limit后,它生成了一个正确的XML文件。