English | 简体中文
- https://jira.sonarsource.com/browse/MMF-1942
- https://community.sonarsource.com/t/badges-on-private-projects/4894/20
- SonarQube 私有项目徽章显示方案
- 1、Install
Compile it yourself, or download the compiled release package.
wget https://github.com/TapTap/sonarqube-badges/releases/download/v0.1/sonarqube-badges-0.1.tar
After decompressing the distribution package, modify the conf.properties
configuration file to configure your sonarqube database
information. Such as:
server.port=8080
mybatis-plus.global-config.banner=false
#required
spring.datasource.url=jdbc:postgresql://qa-sonar.db.com:1921/sonarqube?ssl=false¤tSchema=public
spring.datasource.username=sonar
spring.datasource.password=sonar
#optional: Used for tools interface, request address for assembling badges
sonar.base-url=https://qa-sonar.dev.com
sonar.badges-base-url=http://localhost:8080
Execute startup.sh
to start the application
- 2、Usage
2.1、measure badge interface
GET
/api/project_badges/measure
Request parameters | Type | Description |
---|---|---|
project | string | Identifies the unique ID of the project, a required parameter |
metric | string | metric identification, required parameter, optional(bugs、code_smells、sqale_index、vulnerabilities、security_rating、coverage、duplicated_lines_density、ncloc、sqale_rating、alert_status、reliability_rating) |
branch | string | Branch name, optional parameters |
For example :http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=bugs
Response : SVG
Badges
quality gate badge interface
GET
/api/project_badges/quality_gate
Request parameters | Type | Description |
---|---|---|
project | string | Identifies the unique ID of the project, a required parameter |
branch | string | Branch name, optional parameters |
For example :http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4
Response : SVG
Badges
Get all measure badges of the specified project
URL
collection interface
GET
/api/project_badges_tools/measure/url
Request parameters | Type | Description |
---|---|---|
project | string | Identifies the unique ID of the project, a required parameter |
branch | string | Branch name, optional parameters |
For example : http://localhost:8080/api/project_badges_tools/measure/url?project=server_services_developer_AXaIXEx52AMDJFWZUd_4
Response :
[
{
"bugs": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=bugs"
},
{
"code_smells": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=code_smells"
},
{
"coverage": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=coverage"
},
{
"duplicated_lines_density": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=duplicated_lines_density"
},
{
"ncloc": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=ncloc"
},
{
"sqale_rating": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=sqale_rating"
},
{
"alert_status": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=alert_status"
},
{
"reliability_rating": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=reliability_rating"
},
{
"security_rating": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=security_rating"
},
{
"sqale_index": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=sqale_index"
},
{
"vulnerabilities": "http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=vulnerabilities"
}
]
Get all measure badges of the specified project
markdown
collection interface
GET
/api/project_badges_tools/measure/markdown
Request parameters | Type | Description |
---|---|---|
project | string | Identifies the unique ID of the project, a required parameter |
branch | string | Branch name, optional parameters |
For example : http://localhost:8080/api/project_badges_tools/measure/markdown?project=server_services_developer_AXaIXEx52AMDJFWZUd_4
Response :
[
"[![bugs](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=bugs)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)",
"[![code_smells](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=code_smells)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)",
"[![coverage](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=coverage)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)",
"[![duplicated_lines_density](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=duplicated_lines_density)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)",
"[![ncloc](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=ncloc)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)",
"[![sqale_rating](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=sqale_rating)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)",
"[![alert_status](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=alert_status)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)",
"[![reliability_rating](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=reliability_rating)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)",
"[![security_rating](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=security_rating)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)",
"[![sqale_index](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=sqale_index)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)",
"[![vulnerabilities](http://localhost:8080/api/project_badges/measure?project=server_services_developer_AXaIXEx52AMDJFWZUd_4&metric=vulnerabilities)](https://qa-sonar.dev.com/dashboard?id=server_services_developer_AXaIXEx52AMDJFWZUd_4)"
]
Pull code
git clone https://github.com/TapTap/sonarqube-badges.git
Building
./gradlew assemble
In the root directory of the project, execute the above script. After successful execution, a build directory will be generated in the root directory. The distribution package is in build/distributions/sonarqube-badges-0.1.tar
By linking to the database of sonarqube, the project analysis data of sonarqube can be directly obtained. Then the URL design of sonarqube-badges is the same as sonarqube, SVG
generates the sonarqube of style copy
Open source code, so the style remains exactly the same as sonarqube