Skip to content

Sonar plugin to calculate the variation coverage between the current scan and the default branch.

License

Notifications You must be signed in to change notification settings

kronenthaler/sonar-coveragedelta-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Quality Gate Status Coverage

Sonar Coverage Variation Plugin

A Sonarqube plugin to calculate the variation coverage between the current scan and the previous one.

Requirements

  • Sonarqube 9.0.1+
  • Java 11

Installation

Copy the release jar into the sonar's extensions/plugins folder.

Quality Gate configuration

Define a condition for the Quality Gate that you want to monitor. This cannot be done via the Web UI because the custom metrics are not displayed.

However, it's possible to create the condition using the web APIs.

curl -X POST -u "$SONAR_TOKEN:" "$SONAR_HOST_URL/api/qualitygates/create_condition?error=<error-threshold>&gateName=<qg-name>&metric=coverage_variation&op=LT"

Where:

  • SONAR_TOKEN: is an access token of a user with admin permissions
  • SONAR_HOST_URL: the url to the sonar instance to configure the quality gate condition
  • error-threshold: the maximum percentual difference to allow on new code. Ideally, 0 (per-cent) decrease. But it can be set to -1 or -2 for some leniency.
  • qg-name: the Quality Gate to add the condition to.
  • coverage_variation: this is the new metric we want to add. Do not change this.
  • LT: the direction we want to validate the change of variation. LT means less than <error-threshold> will fail the Quality Gate.

Usage

For safety, the variation scan is disabled by default. To enable it, add the following property to your scanner command:

sonar-scanner -Dsonar.coverage.variation.enabled=true ...

About

Sonar plugin to calculate the variation coverage between the current scan and the default branch.

Topics

Resources

License

Stars

Watchers

Forks