Sign inSign up

aosapps/drone-sonar-plugin

By aosapps

•Updated almost 6 years ago

Drone plugin to integrate with SonarQube.

Image
0

100K+

aosapps/drone-sonar-plugin repository overview

⁠Drone SonarQube Plugin

Code repository: 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 will automatically post the code analysis report to SonarQube immediately after the execution of the associated pipeline finished.

⁠Quickly Start Pipeline Example

Drone v1.0

steps
- name: code-analysis
  image: aosapps/drone-sonar-plugin
  settings:
      sonar_host:
        from_secret: sonar_host
      sonar_token:
        from_secret: sonar_token

Drone v0.8.x

  code-analysis:
    image: aosapps/drone-sonar-plugin
    secrets: [sonar_host, sonar_token]
⁠Secrets:

Safety first, the host and token are stored in Drone Secrets.

  • 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.
⁠Advanced Parameters:
  • ver: Code version, Default value DRONE_BUILD_NUMBER.

  • timeout: Default seconds 60.

  • 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.

  • exclusions: Comma-delimited list of file path patterns to be excluded from analysis.

  • level: Control the quantity / level of logs produced during an analysis. Default value INFO.

    • 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.
  • showProfiling: Display logs to see where the analyzer spends time. Default value false

  • usingProperties: Using the sonar-project.properties file in root directory as sonar parameters. (Not include sonar_host and sonar_token.) Default value false

⁠Notes:
  • projectKey: DRONE_REPO
  • projectName: DRONE_REPO
  • You could also add a file named sonar-project.properties at the root of your project to specify parameters.

SonarQube Parameters: Analysis Parameters⁠

⁠Test your SonarQube Server:

Replace the host and login token depend on your situation:

sonar-scanner \
  -Dsonar.projectKey=Neptune:news \
  -Dsonar.sources=. \
  -Dsonar.projectName=Neptune/news \
  -Dsonar.projectVersion=1.0 \
  -Dsonar.host.url=http://localhost:9000 \
  -Dsonar.login=60878847cea1a31d817f0deee3daa7868c431433

Tag summary

Content type

Image

Digest

Size

149.2 MB

Last updated

almost 6 years ago

docker pull aosapps/drone-sonar-plugin