Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

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 have created a public extension you can install into your VSTS account or a TFS 2015 server. The extension contains the following build steps:

For C# and VB.NET projects

  • SonarQube Scanner for MSBuild - Begin Analysis
  • SonarQube Scanner for MSBuild - End Analysis

All other languages

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

  • Amaury Leve Add SonarQube Extension marketplace screenshot

After installing the extension, follow the steps below to get it running for your build.

Add a SonarQube Service Endpoint

  1. Open the Services page in your Visual Studio Team Services Control Panel
    Click the Settings cog icon in the top bar of the project screen and then click the Services menu.

  2. Click on New Service Endpoint and choose SonarQube.
  3. Specify a Connection Name, the Server URL of your SonarQube Server (including the port if required) and the Authentication Token to use.


  • Amaury Leve Add more details about the token. How to get it
    VAL: changed the Authentication Token text above to a link with the correct location...

Enable the SonarQube Analysis in the Build Definition

  1. Open the Build Defintions page  in your Visual Studio Team Services Control Panel
    Click the Build & Release button on the top bar and then the Builds menu.
  2. Edit an existing Build Definition or create a new one.
  3. Click the Add build step... button.
  4. Select the Build category, then for C# and VB.NET projects add both SonarQube for MSBuild - Begin Analysis and SonarQube for MSBuild - End Analysis build steps.
  5. If your project has a different language, or if it contains mixed languages, for example, C# and JavaScript, add also the SonarQube Scanner CLI build step.
    Amaury Leve - Add screenshot
  6. Drag and drop the SonarQube for MSBuild - Begin Analysis build step before the Visual Studio Build step (or the MSBuild step).
  7. Drag and drop the SonarQube for MSBuild - End Analysis build step after the Visual Studio Test step.
    Optional: To import code coverage into SonarQube, select the Visual Studio Test build step and tick Code Coverage Enabled.
  8. If you added the SonarQube Scanner CLI step, please make sure it is after the Visual Studio Build step.
  9. Click the Save button.

 

Configure SonarQube Analysis

The SonarQube for MSBuild Begin Analysis and SonarQube Scanner CLI have similar configuration options.

  1. SonarQube Endpoint - add or choose an existing SonarQube Endpoint. This sets sonar.host.url, sonar.login and sonar.password.
  2. Project Key - the unique project key in SonarQube. This sets the sonar.projectKey parameter.
  3. Project Name - the name of the project in SonarQube. This sets the sonar.projectName parameter.
  4. Project Version - the version of the project. This sets the sonar.projectVersion parameter.


  5. Additional Settings and Settings File - choose additional command line arguments or a settings file for the SonarQube analyser. Note that the format is different for SonarQube Scanner CLI and SonarQube for MSBuild.

 

 

  • No labels