我正在使用jenkins的管道插件,我想为每次运行生成代码覆盖率报告,并将其与管道ui一起显示。有没有可以用来做这件事的插件(例如Cobertura,但它似乎不受管道的支持)?
发布于 2017-05-17 20:15:21
有一种方法可以添加一个管道步骤来发布您的覆盖率报告,但它不会显示在BlueOcean界面下。它将在正常的UI中显示正常。
pipeline {
agent any
stages {
...
}
post {
always {
junit '**/nosetests.xml'
step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '**/coverage.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
}
}
}
请注意,Cobertura插件的参数之一是它将使用的XML (在本例中为‘**/coverage.xml’)。
如果您使用的是python,则需要使用以下内容:
nosetests --with-coverage --cover-xml --cover-package=pkg1,pkg2 --with-xunit test
发布于 2018-12-19 02:00:06
现在,您还可以在Jenkinsfile中直接使用cobertura
命令
stage ("Extract test results") {
cobertura coberturaReportFile: 'path-to/coverage.xml'
}
发布于 2017-02-27 23:25:02
使用指定目录中的command line cobertura-report
生成报告,并将结果作为项目附加。
cobertura-report [--datafile file] --destination dir [--format
html|xml] [--encoding encoding] directory [--basedir dir]
https://stackoverflow.com/questions/36918370
复制相似问题