2

I configured a Jenkins Main Project P to manage two git repository A and B. This main project P only updates git sources and calls sonar analysis on sources from his workspace.

Here's my tree folder.

{Jenkins Install Path} \ workspace \ P 
                                     |-- A 
                                         |-- .git/
                                         |-- all projects A files
                                     |-- B
                                         |-- .git/
                                         |-- all projects B files

When Jenkins runs sonar analysis for P, I got the following error

SCM provider for this project is: git
2664 files to be analyzed
0/2664 files analyzed
Missing blame information for the following files:
(all files)

The error is logical because SonarQube is looking for a .git folder under {Jenkins Install Path} \ workspace \ P. It doesn't exist.

I looked around the internet to find a solution but I didn't find an answer. I am using SonarQube 5.5 installed on windows.

Do you have some idea to make SonarQube working with my configuration ?

This case is different than Sonarqube: Missing blame information for the following files because the root cause is I am using two git folder fetch by a single SonarQube analysis.

Sources I visited and read several times

SonarQube Git Plugin

Seems similar but different issue

Global SCM error in SonarQube

Flows
  • 3,675
  • 3
  • 28
  • 52
  • I think this is less a SonarQube (analysis) question than it is a Git (project structure) question. You might take a look at Git submodules – G. Ann - SonarSource Team Jun 01 '16 at 14:34
  • I understand your answer, but I don't want/ I can't change the structure of my git repository using submodules because modules `A` and `B` are separated git modules for years and `B` is a common modules used by several applications. I am afraid to not be able to use SCM in this configuration. – Flows Jun 01 '16 at 14:59
  • 1
    But you _could_ create a third repo that represents the actual project and do your checkouts inside it as sub-modules. Note that I haven't tested the blame function in this scenario, but theoretically it should work. – G. Ann - SonarSource Team Jun 01 '16 at 15:03
  • Maybe I can create a git repo under Jenkins workspace. I'll try something like that. Thanks – Flows Jun 01 '16 at 15:22
  • Possible duplicate of [Sonarqube: Missing blame information for the following files](https://stackoverflow.com/questions/37432290/sonarqube-missing-blame-information-for-the-following-files) – John Meyer Oct 24 '17 at 19:24

2 Answers2

3

You can setup an analysis job which is triggered by P.

The analysis job can take a parameter which repository inside of the workspace of P should be analysed. The job itself should use the same workspace as P and only call the SonarQube analysis.

CSchulz
  • 10,882
  • 11
  • 60
  • 114
1

Based on @CSchulz's answer I found the solution using SonarQube module

I configured SonarQube to use two submodule corresponding to my A and B git projects. Each project get the name of git module as the important projectBaseDir parametre.

sonar.projectKey=P
sonar.projectName=P
sonar.projectVersion=4.0.0
sonar.binaries=.

sonar.cxx.includeDirectories=Common/Path
sonar.cxx.cppcheck.reportPath=cppCheckReport.xml # Reports are present in A and B forlder

#  2 modules definition
sonar.modules=A,B

# Module A
IHM.sonar.projectBaseDir=A
IHM.sonar.projectName=A
IHM.sonar.sources=.
IHM.sonar.cxx.includeDirectories=XXX

# Module B
Shares.sonar.projectBaseDir=B
Shares.sonar.projectName=B
Shares.sonar.sources=.
Shares.sonar.cxx.includeDirectories=XXX

I needed to figure out some configurations but it works and it is fine for me.

Flows
  • 3,675
  • 3
  • 28
  • 52
  • Unfortionally, this feature seems to be removed with Sonarqube 7.6 https://community.sonarsource.com/t/any-alternative-proposal-for-multi-module-analysis-properties-removed-in-sonarqube-7-6/7429 – Simone Oct 13 '21 at 07:11