Integrate SonarQube in your TFS or VSTS Build

Since the last update to TFS we also have the build steps available to easily integrate SonarQube in your Visual Studio CI process. If you don’t have a SonarQube instance running you can set up one in Azure in nearly no time.

Set up service endpoint for SonarQube

First you have to set up a service endpoint for your SonarQube instance in TFS or VSTS. Go to the settings of your project (“manage project”), go to services and click “New Service Endpoint”. Select “Generic” and enter the URL to your SonarQube instance and the credentials to connect with.

Set up service endpoint for SonarQube

Add and configure build steps

Add the two build steps to your build “SonarQube for MSBuild – Begin Analysis” and “SonarQube for MSBuild – End Analysis”

Add sonarQube build steps

You have to move the “Begin” step before the “Visual Studio Build” and the “End” after the “Visual Studio Test”

In the “Begin” step – select the service endpoint you created earlier. Set values for Sonar Project, Key and Version. I want to save the build as a template so I use variables and not fix values.

Since SonarQube v5.2 it’s not longer required to have a database connection.

Configure sonarQube build steps

That’s it. Run the build and your project will show up in your SonarQube instance.

One thought on “Integrate SonarQube in your TFS or VSTS Build

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s