【问题标题】:How to configure jenkins for checkstyle for php project如何为 php 项目的 checkstyle 配置 jenkins
【发布时间】:2014-02-12 09:55:54
【问题描述】:

jenkin for php 项目入门。

以下步骤已配置 1)下载jenkin-1.549 2)安装php插件checkstyle 3)添加项目示例zf2demo

zf2 演示中的 build.xml

<target name="phpcs" >
  <exec executable="phpcs">
    <arg line="--report=checkstyle 
 --report-file=${project.basedir}/build/logs/checkstyle.xml
 --standard=Zend
 ${project.basedir}/*.php" />
  </exec>
 </target>

zf2demo/build 中的phpcs.xml

<ruleset name="zenddemo">
 <description>Description of your coding standard</description>

 <rule ref="Generic.PHP.DisallowShortOpenTag"/>
 <!-- ... -->
</ruleset>

构建成功运行 错误 未找到报告文件。配置错误?

在哪里配置报告文件?我们需要手动创建吗

还有什么需要配置才能生成报告?

在配置部分添加 构建后操作 发布 Checkstyle 分析结果

Checkstyle results  

‘/build/checkstyle.xml’不匹配任何内容:‘’存在但不匹配‘/build/checkstyle.xml’

如何配置这些? 已编辑 从控制台运行时

【问题讨论】:

    标签: php jenkins-plugins jenkins-php


    【解决方案1】:

    去构建并检查控制台输出[原始] phpcs的结果是什么?有什么错误吗?

    phpcs:
         [exec] Result: 1
    

    如果您使用提供的参数直接从控制台运行 phpcs,是否会生成报告文件?

    【讨论】:

    • 文件:C:\wamp\www\zenddemo\index.php ---------------------------- -------------------------------------------------- -- 发现影响 2 行的 2 个错误 ------------------------------------ -------------------------------------------------------- 1 |错误 |行尾字符无效;应为“\n”,但找到“\r\n” 2 |错误 |缺少文件文档注释 ---------------------------------------------- ---------------------------------- 检查一个文件 index.php 我从控制台得到的结果如上
    • 您应该使用构建配置中的所有选项运行 phpcs,即 --report、--report-file、--standard=Zend。并检查是否创建了报告文件
    • 报告文件通过命令行正确生成。在 Checkstyle 结果配置中我们是否需要定义任何文件路径?在项目配置或类似的东西我错过了
    • 我们需要自己创建一个checkstyle.xml吗?并告诉路径? checkstyle.xml 的格式将如何
    • 使用 ${basedir} 而不是 ${project.basedir}。 checkstyle.xml 应该由 phpcs 生成,因为您提供选项 --report-file=${basedir}/build/logs/checkstyle.xml 在 postbuild 动作中发布 Checkstyle 分析结果应该是 'build/logs/checkstyle.xml'跨度>
    猜你喜欢
    • 2015-07-01
    • 2017-10-31
    • 2012-01-11
    • 2013-09-07
    • 1970-01-01
    • 1970-01-01
    • 2011-12-25
    • 2017-02-24
    • 2011-04-09
    相关资源
    最近更新 更多