Changing only sonar-project.properties doesn't allow to rerun the analysis

Hello,

Here are some info:

  • ALM used: Gitlab
  • CI system: Jenkins
  • Scanner command used: sonar-build-wrapper\compile_commands.json
  • Languages of the repository: C++

I ran a Sonar analysis, and many errors came from a library file (doctest.h). I then modified sonar-project.properties to add this file to sonar.exclusions, pushed the modification, and ran again the analysis.

But as no modification is detected, the analysis fails:
java.lang.IllegalStateException: The Compilation Database JSON file was found but 0 C/C++/Objective-C files were analyzed

Hi,

I don’t understand what’s failing. Are you re-building? Can you provide the full analysis log?

 
Ann

Yes, I rebuild, but no code has been changed. The only modified file is sonar-project.properties.
But I want to do again an analysis.

Hi,

Can you provide the full log, not just the error at the end?

 
Thx,
Ann

[Pipeline] { (Sonar)
[Pipeline] updateGitlabCommitStatus
[Pipeline] echo
14:44:31  [2025-02-03T13:44:31.770Z] Running analyser script: & 'C:\Program Files (x86)\Jenkins\workspace\MyProject\jenkinsFiles\libJenkins\check_sonar_quality_gate.ps1' -module MyProjectSonarKey -branch main
[Pipeline] powershell
14:44:33  [2025-02-03T13:44:33.178Z] False
[Pipeline] echo
14:44:33  [2025-02-03T13:44:33.277Z] Branch already analyzed = false
[Pipeline] echo
14:44:33  [2025-02-03T13:44:33.290Z] The Sonar analysis will have to run twice.
[Pipeline] dir
14:44:33  [2025-02-03T13:44:33.302Z] Running in C:\Program Files (x86)\Jenkins\workspace\MyProject/CMake/source/modules/MyProjectSonarName
[Pipeline] {
[Pipeline] tool
[Pipeline] echo
14:44:33  [2025-02-03T13:44:33.643Z] Running SonarScanner with suffix -'Dsonar.branch.name=main'...
[Pipeline] withSonarQubeEnv
14:44:33  [2025-02-03T13:44:33.664Z] Injecting SonarQube environment variables using the configuration: SonarCloud
[Pipeline] {
[Pipeline] echo
14:44:33  [2025-02-03T13:44:33.806Z] $env:BUILD_WRAPPER_OUTPUT_DIR='../../../bin/sonar-build-wrapper' ; & "C:\Program Files (x86)\Jenkins\tools\hudson.plugins.sonar.SonarRunnerInstallation\SonarQube_Scanner_from_Maven_Central/bin/sonar-scanner.bat" -'Dsonar.branch.name=main'
[Pipeline] powershell
14:44:51  [2025-02-03T13:44:51.834Z] sonar-scanner.bat : 14:44:50.090 ERROR Error during SonarScanner Engine execution
14:44:51  [2025-02-03T13:44:51.835Z] At C:\Program Files (x86)\Jenkins\workspace\MyProject\CMake\source\modules\MyProjectSonarName@tmp\durable-fee11b7c\powershellScript.ps1:1 char:68
14:44:51  [2025-02-03T13:44:51.835Z] + ... -wrapper' ; & "C:\Program Files (x86)\Jenkins\tools\hudson.plugins.so ...
14:44:51  [2025-02-03T13:44:51.835Z] +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14:44:51  [2025-02-03T13:44:51.835Z]     + CategoryInfo          : NotSpecified: (14:44:50.090 ER...ngine execution:String) [], RemoteException
14:44:51  [2025-02-03T13:44:51.835Z]     + FullyQualifiedErrorId : NativeCommandError
14:44:51  [2025-02-03T13:44:51.835Z]  
14:44:51  [2025-02-03T13:44:51.835Z] java.lang.IllegalStateException: The Compilation Database JSON file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
14:44:51  [2025-02-03T13:44:51.835Z]   * you are correctly invoking the scanner with correct configuration
14:44:51  [2025-02-03T13:44:51.835Z]   * your compiler is supported
14:44:51  [2025-02-03T13:44:51.835Z]   * you are providing the path to the correct Compilation Database JSON
14:44:51  [2025-02-03T13:44:51.835Z]   * you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
14:44:51  [2025-02-03T13:44:51.835Z] 	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:314)
14:44:51  [2025-02-03T13:44:51.835Z] 	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:190)
14:44:51  [2025-02-03T13:44:51.835Z] 	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:63)
14:44:51  [2025-02-03T13:44:51.835Z] 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
14:44:51  [2025-02-03T13:44:51.835Z] 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:51)
14:44:51  [2025-02-03T13:44:51.835Z] 	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
14:44:51  [2025-02-03T13:44:51.835Z] 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
14:44:51  [2025-02-03T13:44:51.835Z] 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
14:44:51  [2025-02-03T13:44:51.835Z] 	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:190)
14:44:51  [2025-02-03T13:44:51.835Z] 	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:186)
14:44:51  [2025-02-03T13:44:51.835Z] 	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:157)
14:44:51  [2025-02-03T13:44:51.835Z] 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
14:44:51  [2025-02-03T13:44:51.836Z] 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
14:44:51  [2025-02-03T13:44:51.836Z] 	at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(ScannerContainer.java:416)
14:44:51  [2025-02-03T13:44:51.836Z] 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
14:44:51  [2025-02-03T13:44:51.836Z] 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
14:44:51  [2025-02-03T13:44:51.836Z] 	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
14:44:51  [2025-02-03T13:44:51.836Z] 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
14:44:51  [2025-02-03T13:44:51.836Z] 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
14:44:51  [2025-02-03T13:44:51.836Z] 	at org.sonar.scanner.bootstrap.ScannerMain.runScannerEngine(ScannerMain.java:137)
14:44:51  [2025-02-03T13:44:51.836Z] 	at org.sonar.scanner.bootstrap.ScannerMain.run(ScannerMain.java:52)
14:44:51  [2025-02-03T13:44:51.836Z] 	at org.sonar.scanner.bootstrap.ScannerMain.main(ScannerMain.java:38)
14:44:51  [2025-02-03T13:44:51.836Z] 
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:34.749 INFO  Scanner configuration file: C:\Program Files (x86)\Jenkins\tools\hudson.plugins.sonar.SonarRunnerInstallation\SonarQube_Scanner_from_Maven_Central\bin\..\conf\sonar-scanner.properties
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:34.754 INFO  Project root configuration file: C:\Program Files (x86)\Jenkins\workspace\MyProject\CMake\source\modules\MyProjectSonarName\sonar-project.properties
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:34.796 INFO  SonarScanner CLI 6.2.1.4610
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:34.798 INFO  Java 17.0.6 Eclipse Adoptium (64-bit)
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:34.798 INFO  Windows Server 2019 10.0 amd64
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:34.816 INFO  User cache: C:\Windows\system32\config\systemprofile\.sonar\cache
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:35.245 INFO  JRE provisioning: os[windows], arch[amd64]
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:36.128 INFO  Communicating with SonarCloud
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:36.537 INFO  Starting SonarScanner Engine...
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:36.537 INFO  Java 17.0.11 Eclipse Adoptium (64-bit)
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:37.201 INFO  Load global settings
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:37.434 INFO  Load global settings (done) | time=234ms
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:37.438 INFO  Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:37.530 INFO  Loading required plugins
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:37.531 INFO  Load plugins index
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:37.574 INFO  Load plugins index (done) | time=43ms
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:37.574 INFO  Load/download plugins
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:37.651 INFO  Load/download plugins (done) | time=78ms
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:37.970 INFO  Found an active CI vendor: 'Jenkins'
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:37.979 INFO  Load project settings for component key: 'MyProjectSonarKey'
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.021 INFO  Load project settings for component key: 'MyProjectSonarKey' (done) | time=43ms
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.029 INFO  Process project properties
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.041 INFO  Project key: MyProjectSonarKey
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.043 INFO  Base dir: C:\Program Files (x86)\Jenkins\workspace\MyProject\CMake\source\modules\MyProjectSonarName
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.043 INFO  Working dir: C:\Program Files (x86)\Jenkins\workspace\MyProject\CMake\source\modules\MyProjectSonarName\.scannerwork
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.047 INFO  Load project branches
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.144 INFO  Load project branches (done) | time=98ms
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.147 INFO  Check ALM binding of project 'MyProjectSonarKey'
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.184 INFO  Detected project binding: BOUND
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.185 INFO  Check ALM binding of project 'MyProjectSonarKey' (done) | time=37ms
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.186 INFO  Load project pull requests
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.221 INFO  Load project pull requests (done) | time=36ms
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.225 INFO  Load branch configuration
14:44:51  [2025-02-03T13:44:51.837Z] 14:44:38.225 INFO  Load branch configuration (done) | time=1ms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:38.231 INFO  Load quality profiles
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:38.408 INFO  Load quality profiles (done) | time=177ms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:38.413 INFO  Load active rules
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:41.397 INFO  Load active rules (done) | time=2984ms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:41.437 INFO  Exclusions based on SCM info is disabled by configuration
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:41.475 INFO  Organization key: edap-tms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:41.477 INFO  Branch name: main, type: long-lived
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:41.500 INFO  Preprocessing files...
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:41.814 INFO  2 languages detected in 205 preprocessed files
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:41.815 INFO  83 files ignored because of inclusion/exclusion patterns
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.057 INFO  Loading plugins for detected languages
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.058 INFO  Load/download plugins
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.061 INFO  Load/download plugins (done) | time=3ms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.105 INFO  Load project repositories
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.166 INFO  Load project repositories (done) | time=61ms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.170 INFO  Indexing files...
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.170 INFO  Project configuration:
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.170 INFO    Included sources: **/*.c, **/*.cpp, **/*.cxx, **/*.h, **/*.hpp, **/*.hxx
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.171 INFO    Excluded sources: **/build-wrapper-dump.json, **/mosquitto.h, **/mosquittopp.h, **/StackWalker.h, **/StackWalker.cpp, **/json.hpp, topics/**, **/MQTTTopics.h
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.194 INFO  205 files indexed
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.199 INFO  Quality profile for c: Edap-Tms-Deep-Clean
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.199 INFO  Quality profile for cpp: Edap-Tms-Deep-Clean
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.200 INFO  ------------- Run sensors on module MyProjectSonarName
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.233 INFO  Load metrics repository
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.264 INFO  Load metrics repository (done) | time=30ms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.272 INFO  Sensor cache enabled
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.361 INFO  Load sensor cache
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:42.755 INFO  Load sensor cache (404) | time=395ms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.145 INFO  Sensor JaCoCo XML Report Importer [jacoco]
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.146 INFO  'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.148 INFO  No report imported, no coverage information will be imported by JaCoCo XML Report Importer
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.148 INFO  Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.149 INFO  Sensor Java Config Sensor [iac]
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.187 INFO  0 source files to be analyzed
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.194 INFO  0/0 source files have been analyzed
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.195 INFO  Sensor Java Config Sensor [iac] (done) | time=47ms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.195 INFO  Sensor IaC Docker Sensor [iac]
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.297 INFO  0 source files to be analyzed
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.298 INFO  0/0 source files have been analyzed
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.299 INFO  Sensor IaC Docker Sensor [iac] (done) | time=101ms
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.300 INFO  Sensor EnterpriseTextAndSecretsSensor [textenterprise]
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.300 INFO  Available processors: 8
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.301 INFO  Using 8 threads for analysis.
14:44:51  [2025-02-03T13:44:51.838Z] 14:44:43.801 INFO  The property "sonar.tests" is not set. To improve the analysis accuracy, we categorize a file as a test file if any of the following is true:
14:44:51  [2025-02-03T13:44:51.838Z]   * The filename starts with "test"
14:44:51  [2025-02-03T13:44:51.838Z]   * The filename contains "test." or "tests."
14:44:51  [2025-02-03T13:44:51.838Z]   * Any directory in the file path is named: "doc", "docs", "test" or "tests"
14:44:51  [2025-02-03T13:44:51.838Z]   * Any directory in the file path has a name ending in "test" or "tests"
14:44:51  [2025-02-03T13:44:51.839Z] 
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:44.121 INFO  Using git CLI to retrieve untracked files
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:44.198 INFO  Analyzing language associated files and files included via "sonar.text.inclusions" that are tracked by git
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:44.477 INFO  205 source files to be analyzed
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:45.357 INFO  205/205 source files have been analyzed
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:45.357 INFO  Sensor EnterpriseTextAndSecretsSensor [textenterprise] (done) | time=2060ms
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:45.358 INFO  Sensor CFamily [cpp]
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:45.415 INFO  CFamily plugin version: 6.62.0.78645 (829eaa25b0b1054f587bbeeb168e51409c72f905)
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:45.417 INFO  CFamily analysis configuration mode: Compile-Commands
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:45.424 INFO  Using compile commands: C:\Program Files (x86)\Jenkins\workspace\MyProject\CMake\source\modules\MyProjectSonarName\..\..\..\bin\sonar-build-wrapper\compile_commands.json
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:45.425 INFO  Available processors: 8
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:45.428 INFO  Using 8 threads for analysis.
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.069 INFO  Found empty cache on server
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.797 INFO  Compilation database was generated by build-wrapper 6.62
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.907 INFO  Detected compilers: cl=2
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.908 INFO  Number of compilation units in the provided Compilation Database: 2
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.908 INFO  Number of skipped unsupported compilation units: 1
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.909 INFO  Number of skipped non-indexed compilation units: 1
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.909 INFO  Number of skipped duplicate compilation units: 0
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.909 INFO  Number of remaining compilation units to be analyzed: 0
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.912 INFO  Detected standards: 
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.919 INFO  204/205 files marked as unchanged
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:48.919 INFO  Analysis cache: 0/0 hits, 125 bytes
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:50.527 INFO  EXECUTION FAILURE
14:44:51  [2025-02-03T13:44:51.839Z] 14:44:50.529 INFO  Total time: 15.819s
[Pipeline] }
14:44:51  [2025-02-03T13:44:51.942Z] WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeed?
[Pipeline] // withSonarQubeEnv

Hi,

Can you verify that your compilation database is non-empty?

 
Thx,
Ann

I’ll have to wait to come back to my office tomorrow, but I guess it is empty: no code has been changed.

Actually, I can’t: I do not have access to the CI disk. And anyway, I launched other executions of Sonar since the mentionned failure.

1 Like