Add SonarQube coverage via shields.io badge
Asked Answered
L

6

23

I have com.github.xxxxxx:xxxxxx Maven repository and I want add shields badge but I have a invalid badge:

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

enter image description here

Sonarqube xxxxxx project page: https://sonarqube.com/dashboard?id=com.github.xxxxxx%3Axxxxxx

I find a OK sample from an other sonar server:

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

enter image description here

Lorylose answered 1/4, 2017 at 20:1 Comment(2)
I find the problem, my sonarqube is version 6.3 and the sonarqube OK is in version 5.1.2: sonarqube.com/web_api/api/resources (deprecated since 5.4)Devotional
github.com/badges/shields/issues/877Devotional
L
7

Now, i do not use http://shields.io but directly the https://sonarcloud.io web site.

[![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)

Quality Gate SonarCloud Coverage SonarCloud Bugs SonarCloud Vulnerabilities

Lorylose answered 11/12, 2017 at 17:9 Comment(1)
This won't work. Check for the new apis below. https://mcmap.net/q/560893/-add-sonarqube-coverage-via-shields-io-badgeHeptarchy
H
16

New APIS.

 [![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)

Sonarcloud Status SonarCloud Coverage SonarCloud Bugs SonarCloud Vulnerabilities

Heptarchy answered 19/1, 2019 at 11:9 Comment(0)
D
12

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)

There seems to be 11 badges at the moment.

Bugs Code Smells Coverage Duplicated Lines (%) Lines of Code Maintainability Rating Quality Gate Status Reliability Rating Security Rating Technical Debt Vulnerabilities

Dix answered 29/4, 2019 at 19:5 Comment(0)
L
7

Now, i do not use http://shields.io but directly the https://sonarcloud.io web site.

[![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)

Quality Gate SonarCloud Coverage SonarCloud Bugs SonarCloud Vulnerabilities

Lorylose answered 11/12, 2017 at 17:9 Comment(1)
This won't work. Check for the new apis below. https://mcmap.net/q/560893/-add-sonarqube-coverage-via-shields-io-badgeHeptarchy
R
2

I just found this question because i'm also trying to get badges from sonarqube (in my case sonarcloud).

There is an embedded API for badges. Here is the official documentation (I had some time to find it on google): https://next.sonarqube.com/sonarqube/web_api/api/badges

http://shields.io is unfortunately not working anymore with sonarqube.

Retention answered 11/12, 2017 at 15:43 Comment(1)
Oh my version 8.5 it's under /web_api/api/project_badges?internal=trueChemmy
D
2

Update for June 2018 ...

API was deprecated early 2018 and removed in April 2018.

Currently there's a link on a project's lower RHS, "Get project badges", which reveals available image urls for metrics.

Donitadonjon answered 26/6, 2018 at 0:37 Comment(0)
T
1

SonarCloud.io altered API to these urls

https://sonarcloud.io/api/project_badges/quality_gate?project=WcfSoapLogger&branch=master
https://sonarcloud.io/api/project_badges/measure?project=WcfSoapLogger&metric=code_smells
Tuner answered 21/6, 2018 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.