Sonarcloud-scan:4.1.0 failing with OOM when executed from Bitbucket Pipeline

I checked the similar issues reported/resolved in this community. But this don’t help me. Still seeing “Container ‘docker’ exceeded memory limit.”

My Bitbucket Pipeline is as follows.

definitions:
  services:
    docker:
      memory: 15000
  steps:
    - step: &sonarQube-poc
        name: Sonarqube poc
        size: 4x
        max-time: 60
        services:
          - docker
        oidc: true
        clone:
          depth: full
        script:
          - pipe: sonarsource/sonarcloud-scan:4.1.0
            variables:
              DEBUG: 'true'
              SONAR_HOST_URL: "https://sonarqube.us"
              SONAR_SCANNER_OPTS: "-Xmx13000m"

pipelineLog-{45dbe1b1-44d9-4412-860e-34ed67007e23}.txt (84.7 KB). This is the log file from pipeline

Hope I can get a resolution on this.

Thanks,

Rabi

Hey there.

Can you try making this SONAR_SCANNER_JAVA_OPTS?

Hi Colin,

Thanks for responding. I still see the issue with SONAR_SCANNER_JAVA_OPTS.

See the log attached.

pipelineLog-{ac5a7005-a1a7-46c1-b47c-17514aff5de9}.txt (112.8 KB)

Thanks.

In that case, I’m going to escalate this to the team responsible for pythonbugs, since that seems to be where it’s crashing. Hold tight!

Hello,

I don’t think the issue is specifically related to pythonbugs. I don’t think the scanner is using the docker’s RAM.

I am not an expert in bitbucket, but looking at the documentation you sent, the 16GB of the size x4 is split between the docker container (15GB) and the build container (1GB).

But as the scanner is executer on the build container (as its not a docker command) the allocated RAM far exceed the available one.

I suggest you slightly lower the ran of the docker service to 13GB and allocate 2GB to the scanner engine instead of 11GB.

definitions:
  services:
    docker:
      memory: 13000
  steps:
    - step: &sonarQube-poc
        name: Sonarqube poc
        size: 4x
        max-time: 60
        services:
          - docker
        oidc: true
        clone:
          depth: full
        script:
          - pipe: sonarsource/sonarcloud-scan:4.1.0
            variables:
              DEBUG: 'true'
              SONAR_HOST_URL: "https://sonarqube.us"
              SONAR_SCANNER_OPTS: "-Xm2000m"

I hope this helps,
Gabriel

Failed

Container ‘docker’ exceeded memory limit.

name: Analyze Frontend on SonarQube
        size: 4x
        clone:
          depth: full
        caches:
          - sonar
        script:
          - pipe: sonarsource/sonarcloud-scan:4.1.0
            variables:
              SONAR_TOKEN: $SONAR_TOKEN
              SONAR_SCANNER_JAVA_OPTS: "-Xmx2048m -XX:MaxMetaspaceSize=384m -XX:+UseSerialGC"
              EXTRA_ARGS: "-Dproject.settings=sonar-project-frontend.properties"

pipelineLog-{f7ded80e-044b-4909-9586-625ec38f0892}-{03e7c6f0-e106-49b2-baac-cd0626e46a21}.txt (18.3 KB)

06:55:31.108 INFO Project configuration:
06:55:31.109 INFO Excluded sources: /node_modules/, /dist/, /coverage/, **/.min.js, **/.config.js, **/.config.ts, **/index.html, /public/, **/.json, **/.css, **/.scss, **/.svg, **/.png, **/.jpg, **/.ico, **/.woff, **/.woff2, **/.ttf, **/.eot, **/build-wrapper-dump.json
06:55:31.109 INFO Excluded tests: **/.test.ts, **/.test.tsx, **/.spec.ts, **/.spec.tsx
06:55:31.118 INFO 5 files indexed (done) | time=10ms
06:55:31.130 INFO Quality profile for ts: Sonar way
06:55:31.131 INFO ------------- Run sensors on module $SONAR_PROJECT_KEY
06:55:31.195 INFO Load metrics repository
06:55:31.334 INFO Load metrics repository (done) | time=140ms
06:55:31.347 INFO Sensor cache enabled
06:55:31.356 INFO Load sensor cache
06:55:31.703 INFO Load sensor cache (404) | time=347ms
06:55:32.902 INFO Sensor JasminFileCollectorSensor [jasmin]
06:55:32.905 INFO Sensor JasminFileCollectorSensor [jasmin] (done) | time=3ms
06:55:32.907 INFO Sensor IaC hadolint report Sensor [iac]
06:55:32.911 INFO Sensor IaC hadolint report Sensor [iac] (done) | time=4ms
06:55:32.912 INFO Sensor Java Config Sensor [iac]
06:55:32.925 INFO There are no files to be analyzed for the Java language
06:55:32.927 INFO Sensor Java Config Sensor [iac] (done) | time=14ms
06:55:32.928 INFO Sensor IaC Docker Sensor [iac]
06:55:32.929 INFO Sensor IaC Docker Sensor is restricted to changed files only
06:55:32.963 INFO There are no files to be analyzed for the Docker language
06:55:32.964 INFO Sensor IaC Docker Sensor [iac] (done) | time=35ms
06:55:32.965 INFO Sensor IaC GitHub Actions Sensor [iac]
06:55:32.967 INFO There are no files to be analyzed for the GitHub Actions language
06:55:32.968 INFO Sensor IaC GitHub Actions Sensor [iac] (done) | time=3ms
06:55:32.970 INFO Sensor IaC Shell Sensor [iac]
06:55:32.971 INFO There are no files to be analyzed for the Shell language
06:55:32.972 INFO Sensor IaC Shell Sensor [iac] (done) | time=2ms
06:55:32.974 INFO Sensor JavaScript/TypeScript analysis [javascript]
06:55:33.478 INFO Detected os: Linux arch: amd64 alpine: false. Platform: LINUX_X64
06:55:33.480 INFO Deploy location /opt/sonar-scanner/.sonar/js/node-runtime, tagetRuntime: /opt/sonar-scanner/.sonar/js/node-runtime/node, version: /opt/sonar-scanner/.sonar/js/node-runtime/version.txt
06:55:37.538 INFO Configured Node.js --max-old-space-size=2048.
06:55:37.539 INFO Using embedded Node.js runtime.
06:55:37.539 INFO Using Node.js executable: ‘/opt/sonar-scanner/.sonar/js/node-runtime/node’.
time=“2026-02-08T06:57:13Z” level=error msg=“error waiting for container: unexpected EOF”

Hi,

It looks like this may be related to the memory allocation to the Bitbucket pipeline. Can you grant more memory there?

 
Ann