SonarQube Error: java.lang.RuntimeException

Hi,

I am trying to execute sonar analysis stage through Jenkins pipeline to display the coverage for my C++ solution.
Using vstest.console.exe, i am running my unit tests to collect code covergae and Unit test report with parameters /logger:“trx;LogFileName=UnitTestResults.trx;” /EnableCodeCoverage /collect:“Code Coverage”
Then using CodeCoverage.exe to analyze above produced coverage and generate CppCoverage.xml.
In Sonar Stage, using TestCovergaeProperty sonar.cfamily.vscoveragexml.reportsPath
Getting Below error in the Sonnar Scanner stage:
17:16:54.916 INFO: Sensor VisualStudioCoverage [cpp]
17:16:54.919 INFO: Parsing C:\JenkinsWorkspace\workspace\amework_feature_SonarQubeSetting@2\TestResultsCPP\NexusCppCoverage.xml
17:16:55.227 INFO: Load project repositories
17:16:55.396 INFO: Load project repositories (done) | time=169ms
17:16:55.396 DEBUG: ‘source/Hal/Devices/Etheral/Ethernet-Server/SomeIpService.cpp’ generated metadata with charset ‘windows-1252’
17:16:55.429 DEBUG: ‘source/Hal/Devices/Etheral/Ethernet-Server/SomeIpService.h’ generated metadata with charset ‘windows-1252’
17:16:55.448 INFO: ------------------------------------------------------------------------
17:16:55.449 INFO: EXECUTION FAILURE
17:16:55.449 INFO: ------------------------------------------------------------------------
17:16:55.449 INFO: Total time: 14.025s
17:16:55.560 INFO: Final Memory: 40M/662M
17:16:55.560 INFO: ------------------------------------------------------------------------
17:16:55.560 ERROR: Error during SonarScanner execution
java.lang.RuntimeException: java.nio.file.FileSystemException: D:\agent_work\13\s\binaries\amd64ret\inc\vcruntime_new.h: The device is not ready.

at com.sonar.cpp.plugin.visualstudio.VisualStudioCoverageSensor.realPath(VisualStudioCoverageSensor.java:94)
at com.sonar.cpp.plugin.visualstudio.VisualStudioCoverageSensor.execute(VisualStudioCoverageSensor.java:69)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:392)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:385)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Caused by: java.nio.file.FileSystemException: D:\agent_work\13\s\binaries\amd64ret\inc\vcruntime_new.h: The device is not ready.

at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:90)
at sun.nio.fs.WindowsLinkSupport.getRealPath(WindowsLinkSupport.java:259)
at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:836)
at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:44)
at com.sonar.cpp.plugin.visualstudio.VisualStudioCoverageSensor.realPath(VisualStudioCoverageSensor.java:90)

Hello @rmurarka,

We are trying to access this file D:\agent_work\13\s\binaries\amd64ret\inc\vcruntime_new.h that is mentioned in the report. We are throwing an exception because it is inaccessible. Check why this file is not accessible on your machine in the analysis stage.

Hi @Abbas_Sabra ,
vcruntime_new.h file is present in the folder where it should be i.e. C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include
And the strange thing is the setup where this is running doesn’t have D: drive then why sonarscanner is trying to search in D: drive.
One more point when ran the same command in my laptop, it’s working fine without any exception but we have a separate system to run Jenkins pipeline and there it’s not working with the exception mentioned in above post.

@rmurarka, It must be coming from the report file. Can you share C:\JenkinsWorkspace\workspace\amework_feature_SonarQubeSetting@2\TestResultsCPP\NexusCppCoverage.xml of the failed run with me?

Thanks,

Hi @Abbas_Sabra ,

Please find the attached NexusCppCoverage.xml file of the failed run.
NexusCppCoverage.zip (533.4 KB)

Hello @rmurarka,

As expected it is a problem in the report, we are just trying to interpret the report and the report includes a non-existing path. removing this entry from the report should make it work

        <source_file id="31" path="D:\agent\_work\13\s\binaries\amd64ret\inc\vcruntime_new.h" checksum_type="MD5" checksum="7D9ED9BD104174138EC9620D5DFA6B73">
        </source_file>

It seems to be the only file in D drive in the xml. Try to figure out why is this directory ending up in your coverage report.

Thanks,