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.
Add and configure build steps
Add the two build steps to your build “SonarQube for MSBuild – Begin Analysis” and “SonarQube for MSBuild – End Analysis”
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.
That’s it. Run the build and your project will show up in your SonarQube instance.