在我的Freestyle Jenkins工作中,我可以添加构建后操作,以使用插件Clover PHP生成代码覆盖率报告,并使用Checkstyle插件生成分析。
但是,我喜欢使用Pipeline Jenkins作业,因为它有stage视图。使用Pipeline作业,我需要设置Jenkinsfile中的所有内容。如何在Jenkinsfile中包含Clover和Checkstyle插件函数?他们的页面上没有文档。
发布于 2017-01-19 03:04:44
由于您希望与之集成的这两个东西都有CLI接口,因此您可以只使用Jenkinsfile中的sh操作来调用它们的CLI来调用外壳命令。下面是三叶草PHP文档中的一个示例:
sh "phpunit --log-junit 'reports/unitreport.xml' --coverage-html 'reports/coverage' --coverage-clover 'reports/coverage/coverage.xml' test/"Junit日志的位置将根据您在项目中放置的位置而有所不同。必须先运行junit步骤,然后才能运行此步骤。
Checkstyle also has a CLI,您可以通过类似的方式从Jenkinsfile中的sh操作调用它。
只要您将生成的HTML文件与构建一起存档,您就可以通过构建页面上的“build Artifacts”链接导航到生成的HTML文件来阅读它们。示例URL结构可能如下所示:
https://ci.example.com/job/develop/342/artifact/reports/coverage/index.html对于更深层次的集成,这些工具可能需要显式的Jenkins Pipeline支持。
发布于 2017-06-28 19:09:44
为了完成其他答案,Clover PHP没有jenkins管道支持……但是你不需要这个插件,你所需要的就是Clover Plugin
安装一个,然后在示例的jenkinsfile中添加以下内容:
step([
$class: 'CloverPublisher',
cloverReportDir: 'reports/coverage',
cloverReportFileName: 'coverage.xml',
healthyTarget: [methodCoverage: 70, conditionalCoverage: 80, statementCoverage: 80],
unhealthyTarget: [methodCoverage: 50, conditionalCoverage: 50, statementCoverage: 50],
failingTarget: [methodCoverage: 0, conditionalCoverage: 0, statementCoverage: 0]])这就是我在当前项目中使用的。
发布于 2017-01-19 23:34:30
经过多次修改,我成功地在管道上运行了Checkstyle,如下所示:
stage ('Static code analysis') {
sh "sudo phpcs --config-set ignore_warnings_on_exit 1 --report=checkstyle --report-file=checkstyle-result.xml -q /code"
step([$class: 'hudson.plugins.checkstyle.CheckStylePublisher', pattern: 'checkstyle-*'])
}第一步生成报告,第二步调用Checkstyle插件来处理报告。我没有使用三叶草PHP,所以不能帮助你。
https://stackoverflow.com/questions/41727010
复制相似问题