新的代码覆盖率指标未从SonarQube 5.3 API返回值 [英] New code coverage metrics not returning values from SonarQube 5.3 API

查看:437
本文介绍了新的代码覆盖率指标未从SonarQube 5.3 API返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过api获取单元测试覆盖率数据以进行新代码更改.指标.我可以在SonarQubeDashboard中看到数据,但api不会为指标返回任何值,例如:

I need to fetch unit test coverage data for new code changes via the api. The metrics. I can see the data in SonarQubeDashboard but the api is not returning any values for the metrics like:

  1. new_coverage
  2. new_line_coverage (等等)
  1. new_coverage
  2. new_line_coverage (etc)

我正在调用api:

https:///api/resources?format = json& metrics = ncloc,line_coverage,new_line_coverage

https:///api/resources?format=json&metrics=ncloc,line_coverage,new_line_coverage

即使公共Nemo实例也不返回以下指标值:

Even the Public Nemo Instance does not return these metric values:

https://nemo.sonarqube. org/api/resources?format = json& metrics = ncloc,line_coverage,new_line_coverage,new_coverage

上述API对于每个项目仅返回ncloc和line_coverage.

The above API is returning only ncloc and line_coverage for each and every project.

请不要告诉我检查这些指标在版本中是否不可用.如果您调用API,它们就是:

Please dont tell me to check if these metrics are not available in the version. They are, if you invoke the API:

https://nemo.sonarqube.org/api/metrics/search

推荐答案

现代方式(api/measures/component)

SonarQube的api/resources Web API 已弃用,您应该使用api/measures/component (从5.4开始).

The modern way (api/measures/component)

SonarQube's api/resources Web API is deprecated, you should use api/measures/component instead (since 5.4).

此项目为例:

https://nemo.sonarqube.org/api/measures/component?componentKey=org.sonarsource.php%3Aphp&metricKeys=ncloc,line_coverage,new_line_coverage,new_coverage&alitionalFields=度量标准,期限

旧方法(api/资源)

如果您真的很喜欢api/resources(例如旧的SonarQube版本),请记住,对于 new 指标,有一个时间增量概念( new ,因为它是?),所以您必须在请求中添加includetrends=true.让我们以您的示例为例:

The old way (api/resources)

If you're really stuck with api/resources (e.g. old SonarQube version), then keep in mind that for new metrics there is a notion of time delta (new since when ?), so you have to add includetrends=true to your request. Let's do that with your example:

https://nemo.sonarqube.org/api/resources?format=json&metrics=ncloc,line_coverage,new_line_coverage,new_coverage&includetrends=true

这将为您提供new_coveragenew_line_coverage(对于确实具有覆盖范围和SCM信息的项目).

This gives you new_coverage and new_line_coverage (for the projects which do have coverage and SCM information available).

这篇关于新的代码覆盖率指标未从SonarQube 5.3 API返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆