首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >jenkins管道作业的Cobertura代码覆盖率报告

jenkins管道作业的Cobertura代码覆盖率报告
EN

Stack Overflow用户
提问于 2016-04-28 22:56:25
回答 3查看 33.9K关注 0票数 50

我正在使用jenkins的管道插件,我想为每次运行生成代码覆盖率报告,并将其与管道ui一起显示。有没有可以用来做这件事的插件(例如Cobertura,但它似乎不受管道的支持)?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-05-17 20:15:21

有一种方法可以添加一个管道步骤来发布您的覆盖率报告,但它不会显示在BlueOcean界面下。它将在正常的UI中显示正常。

代码语言:javascript
复制
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,则需要使用以下内容:

代码语言:javascript
复制
nosetests --with-coverage --cover-xml --cover-package=pkg1,pkg2 --with-xunit test
票数 46
EN

Stack Overflow用户

发布于 2018-12-19 02:00:06

现在,您还可以在Jenkinsfile中直接使用cobertura命令

代码语言:javascript
复制
stage ("Extract test results") {
    cobertura coberturaReportFile: 'path-to/coverage.xml'
}

来源:https://issues.jenkins-ci.org/browse/JENKINS-30700

票数 42
EN

Stack Overflow用户

发布于 2017-02-27 23:25:02

使用指定目录中的command line cobertura-report生成报告,并将结果作为项目附加。

代码语言:javascript
复制
cobertura-report   [--datafile   file]    --destination  dir  [--format
       html|xml]  [--encoding encoding]  directory [--basedir dir]
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36918370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档