Running the Sonar cloud Analyzer for a C# solution with 100+ mostly small projects, we get the following error running the SonarCloudAnalzye step of our devops pipeline:
ERROR:
java.lang.OutOfMemoryError: Java heap space
at com.sonar.A.D.B(na:3037)
at com.sonar.A.D.B(na:2407)
at com.sonar.security.E.readUcfg(na:216)
at com.sonar.security.E.executeChecks(na:1776)
at com.sonar.security.E.execute(na:2031)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:51)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:468)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:464)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:420)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:130)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
ERROR:
##[error]The SonarScanner did not complete successfully
15:16:38.333 Post-processing failed. Exit code: 1
The SonarScanner did not complete successfully
15:16:38.333 Post-processing failed. Exit code: 1
##[error]The process 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.30.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
We are using a Microsoft hosted build agent, so we have no control over the size of the host VM, and all setup has to be done within the pipeline. We had added the prepare and analyze steps to the pipeline as per the instructions in the project linking tutorial.
I’ve seen solutions for similar issues on sonar qube of setting SONAR_SCANNER_OPTS. Is there something we can specify on the SonarCloudAnalzye step to configure java memory limits?
Our yaml currently contains:
- task: SonarCloudAnalyze@1
We are using Sound Cloud Extension for DevOps: V1.34.2