- ALM used Azure DevOps
- CI system used Azure DevOps
- Languages of the repository: C#
Hi,
I’ve observed strange behaviour and I’ve got no idea how to solve it. Maybe you will have some tips&tricks to solve it
The case is in Azure DevOps pipeline which has got strategy matrix to build a couple of different applications. One of build application inside is the classic .NET application with some dependecnces. The application is building by struct like this:
"$(System.DefaultWorkingDirectory)\SonarScanner.MSBuild.exe" begin /k:"project_key" /o:"organisation" /d:sonar.token="$(SONAR_TOKEN)" /d:sonar.scanner.scanAll=false /d:sonar.configMode="file" /d:sonar.configFile="$(System.DefaultWorkingDirectory)\<path>\sonar-project.properties"
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" "$(System.DefaultWorkingDirectory)\<path>\Solution.sln" /p:SonarQubeTargetsImported=false /m /p:platform="any cpu" /p:configuration="Release" /t:Rebuild /p:TargetFramework=net48
"$(System.DefaultWorkingDirectory)\SonarScanner.MSBuild.exe" end /d:sonar.token="$(SONAR_TOKEN)"
The begin step work properly, and the build process also. The issue occurs after build process once the SonarCloud analyze comes to end. ACCIDENTALLY, it displays issues with analyzing cpp files between other lines of analyze. The log looks something like this below:
...
2024-11-21T09:06:21.9938375Z INFO: ------------- Run sensors on module CSA-CAL
2024-11-21T09:06:21.9938884Z If you don't want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:
2024-11-21T09:06:21.9939332Z INFO: Sensor C# Project Type Information [csharpenterprise]
2024-11-21T09:06:21.9939646Z
2024-11-21T09:06:21.9940000Z INFO: Sensor C# Project Type Information [csharpenterprise] (done) | time=0ms
2024-11-21T09:06:21.9940472Z sonar.c.file.suffixes=-
2024-11-21T09:06:21.9940806Z INFO: Sensor C# Analysis Log [csharpenterprise]
2024-11-21T09:06:21.9941268Z sonar.cpp.file.suffixes=-
2024-11-21T09:06:21.9941661Z INFO: Sensor C# Analysis Log [csharpenterprise] (done) | time=1ms
2024-11-21T09:06:21.9942134Z sonar.objc.file.suffixes=-
2024-11-21T09:06:21.9942479Z INFO: Sensor C# Properties [csharpenterprise]
2024-11-21T09:06:21.9942783Z
2024-11-21T09:06:21.9943127Z INFO: Sensor C# Properties [csharpenterprise] (done) | time=0ms
2024-11-21T09:06:21.9943431Z
2024-11-21T09:06:21.9943771Z INFO: Sensor JaCoCo XML Report Importer [jacoco]
2024-11-21T09:06:21.9944329Z at com.sonar.cpp.plugin.AnalysisConfiguration.setupAnalysisConfigurationMode(AnalysisConfiguration.java:644)
2024-11-21T09:06:21.9945114Z 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
2024-11-21T09:06:21.9945793Z at com.sonar.cpp.plugin.AnalysisConfiguration.setupPluginPropertiesConfig(AnalysisConfiguration.java:140)
2024-11-21T09:06:21.9946254Z INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
2024-11-21T09:06:21.9946587Z at com.sonar.cpp.plugin.AnalysisConfiguration.<init>(AnalysisConfiguration.java:114)
2024-11-21T09:06:21.9946936Z at com.sonar.cpp.plugin.CFamilySensor.prepareAnalysisConfig(CFamilySensor.java:405)
2024-11-21T09:06:21.9947252Z at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:208)
2024-11-21T09:06:21.9947528Z INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
2024-11-21T09:06:21.9947830Z at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:184)
2024-11-21T09:06:21.9948220Z INFO: Sensor Java Config Sensor [iac]
2024-11-21T09:06:21.9948774Z at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:63)
2024-11-21T09:06:21.9949175Z INFO: 0 source files to be analyzed
2024-11-21T09:06:21.9949686Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
2024-11-21T09:06:21.9950092Z INFO: 0/0 source files have been analyzed
2024-11-21T09:06:21.9950617Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:51)
2024-11-21T09:06:21.9951029Z INFO: Sensor Java Config Sensor [iac] (done) | time=1ms
2024-11-21T09:06:21.9951555Z at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
2024-11-21T09:06:21.9951953Z INFO: Sensor IaC Docker Sensor [iac]
2024-11-21T09:06:21.9952458Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2024-11-21T09:06:21.9952868Z INFO: 0 source files to be analyzed
2024-11-21T09:06:21.9953381Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2024-11-21T09:06:21.9953769Z INFO: 0/0 source files have been analyzed
2024-11-21T09:06:21.9954310Z at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:192)
2024-11-21T09:06:21.9955342Z INFO: Sensor IaC Docker Sensor [iac] (done) | time=5ms
2024-11-21T09:06:21.9970428Z at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:188)
2024-11-21T09:06:21.9970966Z INFO: Sensor Serverless configuration file sensor [security]
2024-11-21T09:06:21.9971870Z at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:159)
2024-11-21T09:06:21.9972318Z INFO: 0 Serverless function entries were found in the project
2024-11-21T09:06:21.9973061Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2024-11-21T09:06:21.9973650Z INFO: 0 Serverless function handlers were kept as entrypoints
2024-11-21T09:06:21.9974061Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2024-11-21T09:06:21.9974411Z at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(ScannerContainer.java:416)
2024-11-21T09:06:21.9974760Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2024-11-21T09:06:21.9975114Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2024-11-21T09:06:21.9975557Z at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
2024-11-21T09:06:21.9975897Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2024-11-21T09:06:21.9976234Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2024-11-21T09:06:21.9976549Z at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
2024-11-21T09:06:21.9977001Z at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
2024-11-21T09:06:21.9977338Z at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
2024-11-21T09:06:21.9977674Z at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2024-11-21T09:06:21.9977953Z at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2024-11-21T09:06:21.9978403Z at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2024-11-21T09:06:21.9978668Z at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2024-11-21T09:06:21.9978974Z at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
2024-11-21T09:06:21.9979279Z at jdk.proxy1/jdk.proxy1.$Proxy0.execute(Unknown Source)
2024-11-21T09:06:21.9979564Z at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
2024-11-21T09:06:21.9979890Z at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
2024-11-21T09:06:21.9980193Z at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
2024-11-21T09:06:21.9980468Z at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
2024-11-21T09:06:21.9980740Z at org.sonarsource.scanner.cli.Main.main(Main.java:62)
2024-11-21T09:06:21.9980960Z ERROR:
2024-11-21T09:06:21.9981184Z INFO: Sensor Serverless configuration file sensor [security] (done) | time=0ms
2024-11-21T09:06:21.9981436Z INFO: Sensor AWS SAM template file sensor [security]
2024-11-21T09:06:21.9981826Z INFO: Sensor AWS SAM template file sensor [security] (done) | time=0ms
2024-11-21T09:06:21.9982099Z INFO: Sensor AWS SAM Inline template file sensor [security]
2024-11-21T09:06:21.9982347Z INFO: Sensor AWS SAM Inline template file sensor [security] (done) | time=0ms
2024-11-21T09:06:21.9982611Z INFO: Sensor EnterpriseTextAndSecretsSensor [textenterprise]
2024-11-21T09:06:21.9982831Z INFO: Available processors: 2
2024-11-21T09:06:21.9983041Z INFO: Using 2 threads for analysis.
2024-11-21T09:06:21.9983456Z 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:
2024-11-21T09:06:21.9983739Z * The filename starts with "test"
2024-11-21T09:06:21.9983947Z * The filename contains "test." or "tests."
2024-11-21T09:06:21.9984188Z * Any directory in the file path is named: "doc", "docs", "test" or "tests"
2024-11-21T09:06:21.9984439Z * Any directory in the file path has a name ending in "test" or "tests"
2024-11-21T09:06:21.9984534Z
2024-11-21T09:06:21.9984752Z INFO: Sensor EnterpriseTextAndSecretsSensor [textenterprise] (done) | time=193ms
2024-11-21T09:06:21.9984982Z INFO: Sensor CFamily [cpp]
2024-11-21T09:06:21.9985219Z INFO: CFamily plugin version: 6.60.0.76379 (5be0f75cd1a7285a862a55f79e785691e99cc32b)
2024-11-21T09:06:21.9985508Z INFO: ------------------------------------------------------------------------
2024-11-21T09:06:21.9985744Z INFO: EXECUTION FAILURE
2024-11-21T09:06:21.9985979Z INFO: ------------------------------------------------------------------------
2024-11-21T09:06:21.9986210Z INFO: Total time: 29.157s
2024-11-21T09:06:21.9986431Z INFO: Final Memory: 60M/204M
2024-11-21T09:06:21.9986671Z INFO: ------------------------------------------------------------------------
2024-11-21T09:06:22.3708793Z The SonarScanner did not complete successfully
2024-11-21T09:06:22.3716772Z 09:06:22.358 Post-processing failed. Exit code: 1
2024-11-21T09:06:22.4622392Z ##[error]Cmd.exe exited with code '1'.
2024-11-21T09:06:22.5096556Z ##[section]Finishing: Build CAL solution and run SonarCloud scan
The classic .NET application depends on another application developed in C++ but this CPP sources are excluded in configured .properties file like this:
...
sonar.tests=<sources_to_test_apps>
sonar.exclusions=<source_to_cpp_app_dir>/**, \
**/*.c, **/*.cpp, **/*.h, **/*.hpp
sonar.cfamily.analysisCache.mode=server
sonar.cfamily.compile-commands=<path>/compile-commands.json
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-
Also the source.test option is configured properly.
Do you have any idea how to fix it? I don’t have any idea…