update docs

This commit is contained in:
Rogan 2018-10-29 20:22:22 +08:00
parent 870b72226b
commit 72e741c565

46
DOCS.md
View File

@ -1,45 +1,69 @@
# Drone SonarQube Plugin ---
date: 2018-08-29T00:00:00+00:00
title: SonarQube
author: aosapps
tags: [ Sonar, SonarQube, Analysis, report ]
logo: sonarqube.svg
repo: aosapps/drone-sonar-plugin
image: aosapps/drone-sonar-plugin
---
The plugin of Drone CI to integrate with SonarQube (previously called Sonar), which is an open source code quality management platform. This plugin can scan your code quality and post the analysis report to your SonarQube server. SonarQube (previously called Sonar), is an open source code quality management platform.
This plugin will automatically post the code analysis report to SonarQube immediately after the execution of the associated pipeline finished.
The below pipeline configuration demonstrates simple usage:
### Quickly Start Pipeline Example
```yaml ```yaml
code-analysis: code-analysis:
image: aosapps/drone-sonar-plugin image: aosapps/drone-sonar-plugin
secrets: [sonar_host, sonar_token] secrets: [sonar_host, sonar_token]
``` ```
Customized parameters could be specified:
```diff
code-analysis:
image: aosapps/drone-sonar-plugin
secrets: [sonar_host, sonar_token]
+ ver: 1.0
+ timeout: 20
+ sources: .
+ level: DEBUG
+ showProfiling: true
+ exclusions: **/static/**/*,**/dist/**/*.js
```
# Secret Reference
### Secrets:
Safety first, the host and token are stored in Drone Secrets. Safety first, the host and token are stored in Drone Secrets.
* `sonar_host`: Host of SonarQube with schema(http/https). * `sonar_host`: Host of SonarQube with schema(http/https).
* `sonar_token`: User token used to post the analysis report to SonarQube Server. Click User -- My Account -- Security -- Generate Tokens. * `sonar_token`: User token used to post the analysis report to SonarQube Server. Click User -- My Account -- Security -- Generate Tokens.
### Advanced Parameters: # Parameter Reference
* `ver`: Code version, Default value `DRONE_BUILD_NUMBER`. * `ver`: Code version, Default value `DRONE_BUILD_NUMBER`.
* `timeout`: Default seconds `60`. * `timeout`: Default seconds `60`.
* `sources`: Comma-separated paths to directories containing source files. * `sources`: Comma-separated paths to directories containing source files.
* `inclusions`: Comma-delimited list of file path patterns to be included in analysis. When set, only files matching the paths set here will be included in analysis. * `inclusions`: Comma-delimited list of file path patterns to be included in analysis. When set, only files matching the paths set here will be included in analysis.
* `exclusions`: Comma-delimited list of file path patterns to be excluded from analysis. * `exclusions`: Comma-delimited list of file path patterns to be excluded from analysis. Example: `**/static/**/*,**/dist/**/*.js`.
* `level`: Control the quantity / level of logs produced during an analysis. Default value `INFO`. * `level`: Control the quantity / level of logs produced during an analysis. Default value `INFO`.
* DEBUG: Display INFO logs + more details at DEBUG level. * DEBUG: Display INFO logs + more details at DEBUG level.
* TRACE: Display DEBUG logs + the timings of all ElasticSearch queries and Web API calls executed by the SonarQube Scanner. * TRACE: Display DEBUG logs + the timings of all ElasticSearch queries and Web API calls executed by the SonarQube Scanner.
* `showProfiling`: Display logs to see where the analyzer spends time. Default value `false` * `showProfiling`: Display logs to see where the analyzer spends time. Default value `false`
### Notes: # Notes
* projectKey: `DRONE_REPO` * projectKey: `DRONE_REPO`
* projectName: `DRONE_REPO` * projectName: `DRONE_REPO`
* You could also add a file named `sonar-project.properties` at the root of your project to specify parameters. * You could also add a file named `sonar-project.properties` at the root of your project to specify parameters.
Code repository: [aosapps/drone-sonar-plugin](https://github.com/aosapps/drone-sonar-plugin). Code repository: [aosapps/drone-sonar-plugin](https://github.com/aosapps/drone-sonar-plugin).
SonarQube Parameters: [Analysis Parameters](https://docs.sonarqube.org/display/SONAR/Analysis+Parameters) SonarQube Parameters: [Analysis Parameters](https://docs.sonarqube.org/display/SONAR/Analysis+Parameters)
# Test your SonarQube Server:
Replace the parameter values with your own
### Test your SonarQube Server:
Replace the host and login token depend on your situation
```commandline ```commandline
sonar-scanner \ sonar-scanner \
-Dsonar.projectKey=Neptune:news \ -Dsonar.projectKey=Neptune:news \