How to integrate SonarQube with Git and Teamcity

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube Version 6.7.5 (build 38563)
  • what are you trying to achieve
    Integrate SonarQube with Git and Teamcity
  • what have you tried so far to achieve this
    Just installed Git plugin

I’m working on a POC for SonarQube enterprise edition. I currently set it up and executed the quality gate profile using the scanner on the code base which is sitting in my localhost on windows OS. I would like to integrate it with git and teamcity for CI. Can someone please help me with proper documentation and steps to set it up for CI using teamcity on git.

My currently look like this:


The source code is on my local windows machine.
If I had to integrate sonarqube with git and execute sonar-scanner on source from git how would my properties file look like. Can some one help me with that.


We (at SonarSource) don’t maintain the TeamCity integrations, so I can only give you a general outline for how this is generally done in CIs.

Set up a job that:

  1. checks out the project
    • you’ll obviously need the relevant SCM plugin installed in your CI
  2. builds your project
    • you’ll need installed in your CI whatever build technology your project requires
  3. analyzes your project
    • if a SonarQube-related plugin is available for your CI that’s probably the easiest route
    • if no plugin is available for your CI, you’ll need to follow the normal directions making your analyzer of choice available in your CI environment.

Then run the job.

BTW, it looks rather suspicious that you have module configuration for a single project in your file. If that’s your analyzer of choice, you should move those configurations to your project’s local file. Also, the configurations you’ve shown in your 2nd post are all commented out, and so have no effect on the analysis regardless of which file they’re in.


Thanks Ann for your reply. I know the scanner properties is commented out. But in my file they are uncommented anyways not to worry about comments. Can you please let me know how the scanner-properties file look like if I had to integrate sonarqube with git and generate a report. How to specify the sources from git?


Your CI job does the checkout, not analysis. There are no property adjustments to make for your SCM.


Then how do I configure source for scanner and trigger scanner for sonarqube from CI?


Take a look at the docs:



I believe JetBrains provide a SonarQube plugin for TeamCity:

I haven’t used it personally (ended up rolling our own solution for TeamCity/SonarQube integration), but it may be worth investigating.



1 Like

Does it support SonarQube community version