If we run this locally:
export SONAR_TOKEN=xxx
mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ourproject
It works fine.
however, using bitbucket pipelines (from the wizard) and maven, after it has compiled the code and run the tests correctly, it then fails with:
“Exception in thread “main” java.lang.OutOfMemoryError: Java heap space”
We tried setting:
SONAR_SCANNER_OPTS to -Xmx4096m
and
MAVEN_OPTS to -Xmx4096m
In repository variables, but this didn’t make a difference.
We tried from -Xmx1024m right up to -xMx8192m which made no difference. It runs fine locally without setting any varibles.
The pipeline is:
image: maven:3-jdk-11
clone:
depth: full # SonarQube Cloud scanner needs the full history to assign issues properly
definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarQube Cloud artifacts will speed up your build
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarQube Cloud
caches:
- maven
- sonar
script:
- mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
artifacts:
- target/**
pipelines: # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
branches:
master:
- step: *build-test-sonarcloud
pull-requests:
'**':
- step: *build-test-sonarcloud
Does anyone have any suggestions?
This is the error:
[INFO] Sensor JavaSensor [java]
[INFO] Configured Java source version (sonar.java.source): 8, preview features enabled (sonar.java.enablePreview): false
[INFO] The Java analyzer is running in a context where unchanged files can be skipped. Full analysis is performed for changed files, optimized analysis for unchanged files.
[INFO] Server-side caching is enabled. The Java analyzer was able to leverage cached data from previous analyses for 7 out of 198 files. These files will not be parsed.
[INFO] Using ECJ batch to parse 132 Main java source files with batch size 53 KB.
[INFO] Starting batch processing.
[INFO] 7% analyzed
[INFO] 7% analyzed
[INFO] 7% analyzed
[INFO] 7% analyzed
[INFO] 7% analyzed
[INFO] 7% analyzed
[INFO] 7% analyzed
[INFO] 7% analyzed
[INFO] 7% analyzed
[INFO] 7% analyzed
[INFO] Optimized analysis for 1 of 11 files.
[INFO] 7% analyzed
[ERROR] [stderr] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space