SonarCloudAnalyze Error in AzureDevOps

Hello everybody,

I’m trying to analyze my code in azuredevops but I’m facing this error that I’ve already tried to resolve by increasing the memory and I can’t do it in any way. Has anyone faced the same problem or know how to help me? Thank you very much.

2023-12-09T05:41:28.1783199Z ##[error]ERROR: Error during SonarScanner execution
2023-12-09T05:41:28.1794153Z ERROR: Error during SonarScanner execution
2023-12-09T05:41:28.1795292Z ##[error]java.lang.OutOfMemoryError: Java heap space
2023-12-09T05:41:28.1795950Z java.lang.OutOfMemoryError: Java heap space

Here’s my pipeline:

- stage: SonarCloudAnalysis
   jobs:
   - job: SonarCloudJob
     pool:
       vmImage: $(vmImageName)
     steps:
     - task: SonarCloudPrepare@1
       inputs:
         SonarCloud: 'AzureDevopsSonarCloud'
         organization: 'XXXXXXXXXXXXX'
         scannerMode: 'CLI'
         configMode: 'manual'
         cliProjectKey: 'XXXXXXXXXX'
         cliProjectName: 'XXXXXXXXXXXX'
         cliSources: '$(Build.SourcesDirectory)'

     - task: SonarCloudAnalyze@1
       inputs:
         jdkversion: 'JAVA_HOME_17_X64'
 env:
        SONAR_SCANNER_HOME: '$(Agent.WorkDirectory)/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.43.2/sonar-scanner'
        options: '-X -Xmx32g'

Hi,

Welcome to the community!

Depending on the size of your project, you may need to bump up the memory allocation several times.

Also, can you share how you’re increasing the memory?

 
Ann