Skip to main content
Version: Early Access

SonarQube Plugin

The SonarQube plugin enables Release to work with reports and metrics from a SonarQube server, supporting quality gates and dashboard tiles for your release pipelines.

important

You must set up a connection to a SonarQube server before adding SonarQube tasks or tiles.
See Set Up a Connection to a Sonar Server.

note

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

Features

  • SonarQube Check Compliance, Check Quality, and Check Blocking Violations tasks (create gates in the release flow)
  • Set Latest Analysis Version task
  • Get Issues, Get Measures, and Get Project Analysis tasks
  • SonarQube analysis summary and metrics trend tiles for dashboards

The Check Compliance, Check Quality, and Check Blocking Violations tasks create a gate in the release flow. If the project metrics do not match the metrics configured in the quality gate, these tasks will fail.

Requirements

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

Set Up a Connection to a Sonar Server

  1. In the navigation pane, under Configuration, click Connections.
  2. Under HTTP Server Connections, next to Sonar:Server, click add button.
  3. Enter a Title for the configuration.
  4. Enter the URL of the server.
  5. Select an Authentication method:
    • None
    • Basic
    • NTLM
    • PAT
    • OAuth2
  6. If required, enter authentication and proxy details.
  7. Click Test to verify the connection.
  8. Click Save.

SonarQube Tasks

The following tasks are available to help you integrate SonarQube analysis and quality gates into your Release pipelines. Each task type is described below with configuration steps and usage details.

Check Compliance

  1. In a Release template, add a task: SonarQube > Check Compliance.

  2. Select the Sonar server in the Server field.

  3. Enter the project ID in the Resource field.

  4. Enter the Branch or Pull Request (default: master branch).

    SonarQube Check Compliance task

Check Quality

  1. Add a task: SonarQube > Check Quality.

  2. Select the Sonar server.

  3. Enter the project ID (Resource).

  4. Enter Branch or Pull Request.

  5. Set thresholds for:

    • Line Coverage (%)
    • Complexity
    • Duplicated Lines Density (%)
    • Violations
  6. To skip a field, enter -1.

    note

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

    SonarQube Check Quality task

Check Blocking Violations

  1. Add a task: SonarQube > Check Blocking Violations.

  2. Select the Sonar server.

  3. Enter the project ID (Resource).

  4. Enter Branch or Pull Request.

  5. Set thresholds for:

    • Blocker Violations
    • Critical Violations
    • Major Violations
  6. To skip a field, enter -1.

    note

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

    SonarQube Check Blocking Violations task

Set Latest Analysis Version

  1. Add a task: SonarQube > Set Latest Analysis Version.

  2. Select the Sonar server.

  3. Enter the project ID (Resource).

  4. Enter the Version to set.

  5. Enter Branch or Pull Request.

    SonarQube Set Latest Analysis Version task

Get Issues

  1. Add a task: SonarQube > Get Issues.

  2. Select the Sonar server.

  3. Enter the project ID (Resource).

  4. Enter Branch or Pull Request.

  5. Enter any additional Parameters.

    SonarQube Get Issues task

Get Measures

  1. Add a task: SonarQube > Get Measures.

  2. Select the Sonar server.

  3. Enter the project ID (Resource).

  4. Enter Branch or Pull Request.

  5. Enter Metric Keys.

  6. Enter any additional Parameters.

    SonarQube Get Measures task

Get Project Analysis

  1. Add a task: SonarQube > Get Project Analysis.

  2. Select the Sonar server.

  3. Enter the project ID (Resource).

  4. Enter any additional Parameters.

    SonarQube Get Project Analysis task

Dashboard Tiles

Add a SonarQube Analysis Summary Tile

The SonarQube analysis summary tile displays metrics for the selected project and version.

  1. Click Dashboards in the navigation bar.

  2. Select a dashboard or create a new one.

    note

    To create a new dashboard, click Add dashboard and provide a name for the dashboard.

  3. Click Configure dashboard.

  4. Click Add tiles.

  5. Hover over SonarQube analysis summary and click Add.

  6. Configure the tile:

    • Title: Name for the tile
    • Server: SonarQube server name
    • Project: Project ID

    SonarQube analysis Summary tile

Add a SonarQube Metrics Trend Per Version Tile

  1. Click Dashboards in the navigation bar.

  2. Select a dashboard.

  3. Click Configure dashboard.

  4. Click Add tiles.

  5. Hover over SonarQube metrics trend per version and click Add.

  6. Configure the tile:

    • Title
    • Server
    • Project
    • Metrics (all must be of the same type, for example, percentage)
    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.

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

  8. In the Render as field, select the type of chart to display.

  9. Click Save.

    SonarQube Summary tile