SonarQube Plugin

The Release SonarQube plugin enables Release to work with reports and metrics from a Sonar server.

Important: You must set up a connection to a Sonar server before adding SonarQube tasks or tiles. For information, see Set up a Sonar server.

Note: In the release flow editor, the SonarQube tasks have a red border.

Features

  • Create a SonarQube Check Compliance task.
  • Create a SonarQube Check Quality task.
  • Create a SonarQube Check Blocking Violations task.
  • Create a Set Latest Analysis Version task.
  • Add a SonarQube analysis summary tile on the release dashboard.
  • Add a SonarQube metrics trend per version tile to a release dashboard.

The SonarQube Check Compliance, Check Quality, and Check Blocking Violations tasks create a gate in the release flow that fails if project metrics do not match the metrics configured in quality gate.

Requirements

The SonarQube plugin requires the following:

  • A Sonar server running and accessible via HTTP(s).
  • A FPR artifact uploaded in the SonarQube for the application.
  • A configured SonarQube quality gate.

Set up a connection to a Sonar server

To set up a connection to a Sonar server:

  1. From the navigation pane, under Configuration, click Connections.
  2. Under HTTP Server Connections, next to Sonar:Sever, click add button.
  3. In the Title field, enter a name for the configuration.
  4. In the URL field, enter the address of the server.
  5. In the Authentication method field, select: None, Basic, Ntlm, or PAT.
  6. If required, enter authentication and proxy details.
  7. Click Test to test the connection.
  8. Click Save.

Create a SonarQube Check Compliance task

To add a SonarQube Check Compliance task:

  1. In the release flow tab of a Release template, add a task type SonarQube > Check Compliance.
  2. Open the added task and in the Server field, select the Sonar server.
  3. In the Branch field, add the branch that allows you to run compliance and extract metrics at a branch level. If you don’t add the branch, it takes master branch as default branch.
  4. In the Resource field, add the project you want to check for compliance.

SonarQube Check Compliance task

Create a SonarQube Check Quality task

To add a SonarQube Check Quality task:

  1. In the release flow tab of a Release template, add a task type SonarQube > Check Quality.
  2. Add the branch and PR number in the respective fields.
  3. Open the task that is added and select Sonar server in the Server field.
  4. In the Resource field, add the project you want to check for compliance.
  5. In the Line Coverage field, provide the expected percentage of coverage.
  6. In the Complexity field, provide the maximum expected complexity for the project.
  7. In the Duplicated Lines Density field, provide the maximum duplicate lines density for the project in percentage.
  8. In the Violations field, provide the number of expected violations for the project.

Note: To skip the fields like Line Coverage, Complexity, Duplicated Lines Density and Violations during the validation, enter -1 as the default value.

SonarQube Check Quality task

Create a SonarQube Check Blocking Violations task

To add a SonarQube Check Blocking Violations task:

  1. In the release flow tab of a Release template, add a task type SonarQube > Check Blocking Violations.
  2. Add the branch and PR number in the respective fields
  3. Open the task that is added and select Sonar server in the Server field.
  4. In the Resource field, add the project you want to check for compliance.
  5. In the Blocker Violations field, provide the maximum expected number of blocker violations.
  6. In the Critical Violations field, provide the maximum expected number of critical violations.
  7. In the Major Violations field, provide the maximum expected number of major violations.

Note: To skip the fields like Blocker Violations, Critical Violations, and Major Violations during the validation, enter -1 as the default value.

SonarQube Check Blocking Violations task

Create a SonarQube Set Latest Analysis Version task

To add a SonarQube Set Latest Analysis Version task:

  1. In the release flow tab of a Release template, add a task type SonarQube > Set Latest Analysis Version.
  2. Add the branch and PR number in the respective fields
  3. Open the task that is added and select Sonar server in the Server field.
  4. In the Resource field, add the project you want to check for compliance.
  5. In the Version field, provide the version to be set in the configured project.

SonarQube Set Latest Analysis Version task

Add a SonarQube analysis summary tile to a release dashboard

The SonarQube analysis summary tile type creates a dashboard tile that displays metrics for the selected project and version.

To configure a SonarQube analysis summary tile:

  1. Click Dashboards, in the top navigation bar.
  2. Select the dashboard that you want to add to the new tile.

Note: To create a new dashboard, Click Add dashboard and provide a name for the dashboard.

  1. Click Configure dashboard.
  2. Click Add tiles.
  3. Hover over SonarQube analysis summary,
  4. Click Add.
  5. On the dashboard, hover over the new SonarQube analysis summary tile, and click configure.
  6. In the Title field, enter the name for the tile.
  7. In the Server field, enter the name of the SonarQube server you want to connect with.
  8. In the Project field, enter the project that you want to display metrics on.

SonarQube analysis Summary tile

Add a SonarQube metrics trend per version tile to a release dashboard

To add a SonarQube metrics trend per version tile:

  1. Click Dashboards on the navigation bar.
  2. Select the dashboard where you want to add the new tile.

Note: To create a new dashboard, Click Add dashboard.

  1. Click Configure dashboard.
  2. Click Add tiles.
  3. Hover over SonarQube metrics trend per version, and select Add.
  4. On the dashboard, hover over the new SonarQube metrics trend per version tile, and click configure.
  5. In the Title field, enter a name for the tile.
  6. In the Server field, enter the name of the SonarQube server to connect with.
  7. In the Project field, add the name project to pull data from.
  8. In the Metrics field, select the metrics you want to add.

Note: Once the metrics type is selected, the same metrics type will be applicable for all Metrics that are measured. For example, if you select a metric that is measured as a percentage, then all other metrics are measured in percentages only.

  1. In the Version filter field, select the versions to display.

Note: Version filters follow semantic versioning. A custom regex can also be used, provided that it is python compatible.

  1. In the Render as field, select the type of chart to display.
  2. Click Save.

SonarQube Summary tile

Release notes

Release SonarQube plugin 22.2.0

Improvements

  • [S-84759] - Added branch field for check compliance task