The new structure of Team Foundation Build gives us a great opportunity to integrate better with your build and release processes from Visual Studio Team Services (VSTS) (formerly VSO) and on-premises Team Foundation Server (TFS) servers. We've created a public extension you can install into your VSTS instance or TFS 2015 server. This extension makes the following tasks available to your Build and Release processes:
- SonarQube Scanner for MSBuild - Begin Analysis
- SonarQube Scanner for MSBuild - End Analysis
- SonarQube Scanner CLI
The extension is open-sourced and available in GitHub SonarQube Scanner for MSBuild repository.
Installing the extension
If you're using Visual Studio Team Services (VSTS) or on-premises Team Foundation Server (TFS) 2015 Update 2 (or newer) you can simply install the extension from the marketplace and follow the instructions below.
After installing the extension, follow the below steps to get it running for your build.
Add a SonarQube Service Endpoint
Click the Settings cog icon in the top bar of the project screen and then click the Services menu.
Click New Service Endpoint and choose SonarQube.
Specify a Connection Name, the Server URL of your SonarQube Server (including the port if required) and the Authentication Token to use.
Enable the SonarQube analysis in the Build Definition
The SonarQube Integration extension offers you two options for analyzing your project:
- SonarQube Scanner for MSBuild
- SonarQube Scanner CLI
SonarQube Scanner for MSBuild
Use this analysis if you need to build your project with MSBuild (or Visual Studio).
Click the Build & Release button on the top bar and then the Builds menu.
Open and edit your build definition.
Click the Add build step... button
Add both SonarQube for MSBuild - Begin Analysis and SonarQube for MSBuild - End Analysis build steps to your build definition.
Drag and drop the SonarQube for MSBuild - Begin Analysis build step before the Visual Studio Build step (or the MSBuild step).
Click the SonarQube for MSBuild - Begin Analysis build step to start the configuration.
Select the SonarQube Endpoint you want to use. The list should display the available SonarQube Endpoints. If you haven't created one you can either click the Add or the Manage buttons.
Fill in the Project Key, Project Name and Project Version you want to use for the analysis.
If the project does not exists into the SonarQube instance it will be created using the given Key, Name and Version and will use the default Quality Profile.
Optional: To import code coverage into SonarQube, select the Visual Studio Test build step and tick Code Coverage Enabled.
Drag and drop the SonarQube for MSBuild - End Analysis build step after the Visual Studio Test step.
Click the Save button.
SonarQube Scanner CLI
Use this analysis for other type of projects.