Hi I do experience this currently error upon the integration to pipeline. How to fix it? I already tried adding SONAR_SCANNER_OPTS in my CI but I still get an error
java.lang.OutOfMemoryError: Java heap space
at org.sonarsource.analyzer.commons.xml.XmlFilePosition.shift(XmlFilePosition.java:83)
at org.sonarsource.analyzer.commons.xml.XmlFilePosition.shift(XmlFilePosition.java:62)
at org.sonarsource.analyzer.commons.xml.XmlFilePosition.moveBefore(XmlFilePosition.java:122)
at org.sonarsource.analyzer.commons.xml.XmlParser.visitAttributes(XmlParser.java:268)
at org.sonarsource.analyzer.commons.xml.XmlParser.visitStartElement(XmlParser.java:199)
at org.sonarsource.analyzer.commons.xml.XmlParser.parseXml(XmlParser.java:132)
at org.sonarsource.analyzer.commons.xml.XmlParser.<init>(XmlParser.java:69)
at org.sonarsource.analyzer.commons.xml.XmlFile.create(XmlFile.java:90)
at com.arkea.satd.sonar.xml.ApigeeXmlSensor.execute(ApigeeXmlSensor.java:131)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$1250/0x0000000100cdf840.run(Unknown Source)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
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 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: Re-run SonarScanner using the -X switch to enable full debug logging.
##[error]The process '/home/vsts/work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/4.36.0/sonar-scanner/bin/sonar-scanner' failed with exit code 1
Finishing: Run Code Analysis
Hello, Colin. The SonarQube that I’m currently using is an Enterprise Version, I’m using an ALM. And the CI that were using is yml in Azure DevOps. Here is the template that were using
Were using the Enterprise Version LTS 9.9. How can I fix the error? We have three templates that were using. The first template I’ve shown is the main template, we’re not allowed to modify it so we can’t define the SONAR_SCANNER_OPTS in there and the second template is for the defining the variables, we named it common-vars, and for the third template, its azure-pipelines, in which where we calling the main template and the variables inside the common-vars. Is there any way using SONAR_SCANNER_OPTS without defining it in the main template?
The Azure DevOps Documentation provides an example of adding a variable when you’re also using a template.
variables:
# a regular variable
- name: myvariable
value: myvalue
# a variable group
- group: myvariablegroup
# a reference to a variable template
- template: myvariabletemplate.yml
Thus you can imagine:
variables:
# a regular variable
- name: SONAR_SCANNER_OPTS
value: <increased memory heap values>
# a reference to a variable template
- template: common-vars.yml
Thank you, it works now. May I ask if how will I upgrade my Sonar Scanner version in Azure DevOps? Currently, we are using the Sonar Scanner 4.8 in which some of our C# codes is not scanned. Here its what it says upon running it to pipeline:
You’re going to need to ask for a difference template that uses the MSBuildscannerMode (along with some other changes), rather than CLI. C# projects cannot be analyzed with the SonarScanner CLI.
There is really no other option than changing entirely the configuration of the SonarQube tasks to sandwich your compilation. There’s no workaround to continue to use the template you’re already using, which works only for non-C#/.NET projects.
But, I am still getting a new error like this, anyway, our pipeline is Docker base
SonarScanner for MSBuild 5.13
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
##[error]02:19:50.762 The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
1. The project has not been built - the project must be built in between the begin and end steps
2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
3. The begin, build and end steps have not all been launched from the same folder
4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
02:19:50.762 The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
1. The project has not been built - the project must be built in between the begin and end steps
2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
3. The begin, build and end steps have not all been launched from the same folder
4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
02:19:50.763 Generation of the sonar-properties file failed. Unable to complete the analysis.
##[error]02:19:50.767 Post-processing failed. Exit code: 1
02:19:50.767 Post-processing failed. Exit code: 1
##[error]The process '/usr/bin/dotnet' failed with exit code 1
Finishing: Run Code Analysis