SonarQube - SCM Git - TeamCity integration problem

Must-share information (formatted with Markdown):

  • Community Edition Version 8.3.1
  • TeamCity Enterprise 2020.2.2
  • Teamcity Tool: SonarScanner for MSBuild
  • Goal: Getting authors (developers) from Git to SonarQube authors for filtering
  • What have you tried so far to achieve this:
    To do this, I’ve updated the SCM provider on SonarQube project settings as “git”. After that TeamCity got an error mentioned below. If I remove the “git” keyword from the SCM provider TeamCity could work but the authors not showing in SonarQube.

[Step 4/4] ERROR: Error during SonarQube Scanner execution
[Step 4/4] INFO: ------------------------------------------------------------------------
[Step 4/4] ERROR: Not inside a Git work tree: F:\TeamcityAgent3\work\580efa6627ad3e98
[Step 4/4] ERROR:
[Step 4/4] The SonarQube Scanner did not complete successfully
[Step 4/4] 17:26:00.3 Post-processing failed. Exit code: 1
[Step 4/4] Process exited with code 1
[Step 4/4] Process exited with code 1 (Step: SonarQube End (SonarScanner for MSBuild: finish analysis))
[Step 4/4] Step SonarQube End (SonarScanner for MSBuild: finish analysis) failed


Welcome to the community!

To get “blame” data and attribute issues, analysis needs to be able to read the project’s SCM information from the file system. So you need to check out the project into your work directory and then fire analysis from that same directory.

Based on the error you’re seeing, you’re triggering analysis from a directory that contains a .git directory.