如何使用Jenkins管道向Github pull请求发布测试覆盖率?

时间:2017-02-09 13:29:13

标签: github jenkins jenkins-pipeline

我有以下设置:Github Enterprise for source,Jenkins管道用于CI。我使用https://github.com/jenkinsci/github-organization-folder-plugin在Github中构建每个pull请求。我可以将构建结果(传递或失败)发布回Github。我想将测试覆盖率结果发布到Github pull请求,以便审核将能够看到它。在切换到管道之前,我使用了https://github.com/jenkinsci/github-pr-coverage-status-plugin。现在它不起作用。

还有其他方法吗?

1 个答案:

答案 0 :(得分:1)

合并拉取请求后,可以将https://github.com/jenkinsci/github-pr-coverage-status-plugin与Jenkins管道一起使用。要做到这一点,需要写

currentBuild.result = 'SUCCESS' step([$class: 'CompareCoverageAction'])

有一个检查,构建状态应为“SUCCESS”,因此您需要在调用插件之前将状态设置为“SUCCESS”,否则不会触发任何内容。可以在插件的Github页面上找到其他说明。