通过 shields.io 徽章添加 SonarQube 覆盖范围

Add SonarQube coverage via shields.io badge

我有 com.github.xxxxxx:xxxxxx Maven 存储库,我想添加盾牌徽章,但我有一个无效徽章:

https://img.shields.io/sonar/https/sonarqube.com/com.github.noraui:noraui/tech_debt.svg

Sonarqube xxxxxx 项目页面:https://sonarqube.com/dashboard?id=com.github.xxxxxx%3Axxxxxx

我从其他声纳服务器找到了一个 OK 样本:

https://img.shields.io/sonar/http/sonar.qatools.ru/ru.yandex.qatools.allure:allure-core/coverage.svg

https://img.shields.io/sonar/http/sonar.qatools.ru/ru.yandex.qatools.allure:allure-core/tech_debt.svg

我刚刚发现了这个问题,因为我也在尝试从 sonarqube(在我的例子中是 sonarcloud)获取徽章。

有一个嵌入式 API 徽章。 这是官方文档(我花了一些时间在 google 上找到它):https://next.sonarqube.com/sonarqube/web_api/api/badges

不幸的是,

http://shields.io 不再使用 sonarqube。

现在,我不使用 http://shields.io but directly the https://sonarcloud.io 网站。

[![Quality Gate](https://sonarcloud.io/api/badges/gate?key=com.github.noraui:noraui)](https://sonarcloud.io/dashboard/index/com.github.noraui:noraui)
[![SonarCloud Coverage](https://sonarcloud.io/api/badges/measure?key=com.github.noraui%3Anoraui&metric=coverage)](https://sonarcloud.io/component_measures/metric/coverage/list?id=com.github.noraui:noraui)
[![SonarCloud Bugs](https://sonarcloud.io/api/badges/measure?key=com.github.noraui%3Anoraui&metric=bugs)](https://sonarcloud.io/component_measures/metric/reliability_rating/list?id=com.github.noraui%3Anoraui)
[![SonarCloud Vulnerabilities](https://sonarcloud.io/api/badges/measure?key=com.github.noraui%3Anoraui&metric=vulnerabilities)](https://sonarcloud.io/component_measures/metric/security_rating/list?id=com.github.noraui%3Anoraui)

SonarCloud.io 将 API 更改为这些网址

https://sonarcloud.io/api/project_badges/quality_gate?project=WcfSoapLogger&branch=master
https://sonarcloud.io/api/project_badges/measure?project=WcfSoapLogger&metric=code_smells

2018 年 6 月更新 ...

API 已于 2018 年初弃用并在 April 2018 中删除。

目前在项目的较低 RHS 上有一个 link,“获取项目徽章”,它显示了指标的可用图像网址。

新 API。

 [![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=metamug_mason&metric=alert_status)](https://sonarcloud.io/dashboard?id=metamug_mason) 
 [![SonarCloud Coverage](https://sonarcloud.io/api/project_badges/measure?project=metamug_mason&metric=coverage)](https://sonarcloud.io/component_measures/metric/coverage/list?id=metamug_mason)
 [![SonarCloud Bugs](https://sonarcloud.io/api/project_badges/measure?project=metamug_mason&metric=bugs)](https://sonarcloud.io/component_measures/metric/reliability_rating/list?id=metamug_mason)
 [![SonarCloud Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=metamug_mason&metric=vulnerabilities)](https://sonarcloud.io/component_measures/metric/security_rating/list?id=metamug_mason)

https://github.com/030/n3dr

[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=bugs)](https://sonarcloud.io/dashboard?id=030_n3dr)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=code_smells)](https://sonarcloud.io/dashboard?id=030_n3dr)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=coverage)](https://sonarcloud.io/dashboard?id=030_n3dr)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=030_n3dr)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=ncloc)](https://sonarcloud.io/dashboard?id=030_n3dr)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=030_n3dr)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=alert_status)](https://sonarcloud.io/dashboard?id=030_n3dr)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=030_n3dr)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=security_rating)](https://sonarcloud.io/dashboard?id=030_n3dr)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=sqale_index)](https://sonarcloud.io/dashboard?id=030_n3dr)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=030_n3dr&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=030_n3dr)

目前好像有11个徽章。