How to get blame info from git for a project spanning across multiple repositories?

Must-share information:

  • SonarQube 6.7.6
  • Scanner 4.0.0.1744
  • C++ (Community) 1.3.0.1677 (cxx)

I have a C++ project (though I think the question is not specific to C++) which has sources stored in several repositories. I have a code coverage file generated with BullsEye. It contains coverage for files from different repositories.

Here is my sonar-project.properties:

sonar.projectKey=MyProject
sonar.projectName=MyProject
sonar.language=c++
sonar.showProfiling=true
sonar.verbose=true
sonar.login=<security token>
sonar.password=
sonar.projectVersion=TRT-TMN_0.1.0.54
sonar.sources=Repo1,Repo2
sonar.sourceEncoding=UTF-8
sonar.cxx.coverage.reportPath=input/bullseyecoverage-result.xml
sonar.cxx.xunit.reportPath=input/xunit-report.xml
sonar.log.level=DEBUG
sonar.cxx.errorRecoveryEnabled=true
sonar.cxx.msbuild.charset=UTF-8

Repo1 and Repo2 folders both are git repositories. The sonar-project.properties file resides in the same folder with them, i.e. it is not contained in any git repository itself. The file structure is as following:

  • Prod1
    • .git
    • sources
  • Prod2
    • .git
    • sources
  • input
    • bullseyecoverage-result.xml
    • xunit-report.xml
  • sonar-project.properties

The analysis works just fine, except it cannot retrieve the blame information, and thus cannot correctly compute the leak period metrics. If I run the analysis with these properties, I have:

18:35:12.433 WARN: SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project.

If I explicitly set sonar.scm.provider=git, then I have:

20:14:26.968 INFO: SCM provider for this project is: git
20:14:26.973 INFO: 18609 files to be analyzed
20:14:26.990 INFO: 0/18609 files analyzed
20:14:27.094 INFO: ------------------------------------------------------------------------
20:14:27.094 INFO: EXECUTION FAILURE
20:14:27.094 INFO: ------------------------------------------------------------------------
20:14:27.095 INFO: Total time: 6:46.221s
20:14:27.178 INFO: Final Memory: 7M/54M
20:14:27.178 INFO: ------------------------------------------------------------------------
20:14:27.178 ERROR: Error during SonarQube Scanner execution
Not inside a Git work tree: E:\dev\prod3

From this topic, I see that I have to set sonar.projectBaseDir to an actual git repository. But what do I do if I have multiple repositories?..

Hello,
The statement you found is right, the scm sensor needs to find scm data to be able to blame files.
There is no way to override the path in which the scm sensor looks for the scm data.
In your situation, you would have to analyse your repos separately or not having scm data.
Regards,
Alex.

1 Like