TeamCity integration with SonarQube is implemented via the open-source SonarQube plugin for TeamCity.
The plugin provides a simple user interface for configuring connection between TeamCity and Sonar servers and allows you to trigger analysis using the SonarQube Runner as a build step in TeamCity. When the analysis is completed, TeamCity automatically publishes the results of the analysis to the SonarQube server.
This page explains how to configure and use TeamCity integration with SonarQube.
On this page:
After the SonarQube runner plugin is installed, the SonarQube Servers page appears in the project settings and the SonarQube Runner is added to the list of the available runners for a Build Step.
Configuring SonarQube Server Connection
To enable the integration, you need to create at least one connection to a SonarQube Server. The connection will be used by TeamCity to send data to the SonarQube server.
SonarQube Servers connections are managed in the SonarQube Servers page of the Project Settings, where the Sonar Qube server name and URL as well as the database settings are specified.
For details on the database settings, see the Sonar documentation. Example settings for different databases can be found here.
The connection defined in a project will be available to all its build configurations and subprojects.
Configuring SonarQube Build Step
After the integration is enabled, you can add and configure the SonarQube Build Runner as the final step of the build you want to run analysis on.
Triggerring the analysis with Maven is not directly supported. To use the SonarQube runner with a Maven project, add the
sonar:sonar goal to your project. See SonarQube documentation for detals.
In the runner settings, you need to select a connection to the server to send the data to. Other fields are to be configured as described in the SonarQube Runner documentation.
sonar-project.properties are partially supported.
You can add any additional parameters for the SonarQube Runner in the "Additional parameters" field of the Advanced Options.
The plugin will trigger the Sonar analysis with a SonarQube Runner and publish the results to the SonarQube server.
Viewing analysis results
Once the build is finished, the View in sonar link appears on the Build Results page allowing you to navigate to the SonarQube dashboard to view the results of the analysis.
SonarQube Build Breaker is supported by the TeamCity plugin: the Build Breaker messages are parsed by TeamCity and added as Build Problems.