Set Up Sonar Server for TFS

SonarQube helps to check the overall health of your source code. This allows you to write cleaner code and it will improve your code base dramatically. SonarQube is capable of integrating into CI engines and facilitate DevOps by providing code quality measurements. It supports multiple languages and makes it easy for you to detect bugs in your code. Quality management of your code bases can be centralized and integration with TFS server and Team services is seamless. Follow the steps below to set up a SonarQube server to be used with TFS.

Below are instructions to setup a SonarQube server on Windows platform with SQL Server.

  1. Install SQL Server 2012 or 2014.

  2. Create SQL Server database named sonar with collation settings set to case-sensitive (CS) and accent-sensitive (AS).https://lh3.googleusercontent.com/-39VYAo-UQh0/WEEE444xP7I/AAAAAAAAH8E/kamPEThlVXU/image_thumb%25255B3%25255D.png?imgmax=800

  3. Download Java Runtime Environment 8 or later and install it. Set JAVA_HOME and JRE_HOME.https://lh3.googleusercontent.com/-iDmWeqehxhM/WEEE6178BOI/AAAAAAAAH8M/sL5WDbHoYG4/image_thumb%25255B7%25255D.png?imgmax=800

  4. Download SonarQube 6.1 and extract the zip file into C:\sonarqubehttps://lh3.googleusercontent.com/-ZNznE6fDh-o/WEEE9FRM7eI/AAAAAAAAH8U/HKTa2H7N10k/image_thumb%25255B11%25255D.png?imgmax=800

  5. Set connection info in C:\sonarqube\conf\sonar.properties
    sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar
    sonar.jdbc.username=sonarqube
    sonar.jdbc.password=  

  6. In SQL Configuration Manager, enable TCP/IP for SQL network.https://lh3.googleusercontent.com/--s7qlc5lc88/WEEFAR2T9uI/AAAAAAAAH8c/nJTEy47U4ZA/image_thumb%25255B19%25255D.png?imgmax=800 https://lh3.googleusercontent.com/-sb5m4y_3ltE/WEEFD1XuFrI/AAAAAAAAH8k/WbXgqXLZBxc/image_thumb%25255B18%25255D.png?imgmax=800 

  7. Restart SQL services

  8. Run startsonar.bat in C:\sonarqube\bin\windows-x86-64, to test. This creates the tables in DB. Sonar is running. https://lh3.googleusercontent.com/-P8i236wj_Fk/WDwHF3wavUI/AAAAAAAAH7g/_ntdGIG6bSI/image_thumb%25255B5%25255D.png?imgmax=800
    Browse SonarQube at http://localhost:9000 (the default System administrator credentials are admin/admin).

  9. Stop by pressing ctrl+c
    To install:

  10. Install/uninstall NT service (may have to run these files via Run As Administrator):
    %SONARQUBE_HOME%/bin/windows-x86-``32``/InstallNTService.bat
    %SONARQUBE_HOME%/bin/windows-x86-``32``/UninstallNTService.bat

  11. Start/stop the service:
    %SONARQUBE_HOME%/bin/windows-x86-``32``/StartNTService.bat
    %SONARQUBE_HOME%/bin/windows-x86-``32``/StopNTService.bat

Allow firewall inbound port 9000 to make http://sonarsvr.domainx.local:9000/ work.
https://lh3.googleusercontent.com/-nQJ1v4lOwBs/WDwHHJlIWGI/AAAAAAAAH7o/1KGYL8dEUs8/image_thumb%25255B7%25255D.png?imgmax=800