SonarQube REST APIs : Read Metrics for individual projects

后端 未结 1 946
执念已碎
执念已碎 2021-02-09 10:02

My question:

I am using SonarQube version 7.1 and trying to extract the metrics and quality gate related to individual projects.

What we

1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-09 10:36

    You could do this:

    Call the API api/metrics/search first to get a (json) list of all the metrics and then iterate over that list and create a comma separated string of all the metric keys.

    For example something like this: ncloc,complexity,violations .. as mentioned in the parameters example value in the API documentation here.

    Then you could just add this comma separated list to the url as a parameter something like: http://MY_HOST/api/measures/component?metricKeys=ncloc,complexity,violations&component=project_key

    and call it once to get the response for all metrics.

    Also, I haven't tried this, but as per the latest documentation, the parameter component is optional. So if you omit that, ideally you should get a response with metrics of all the projects.

    0 讨论(0)
提交回复
热议问题