SonarCloud analysis failed - Killed sonar-scanner

Hi all,

I’m trying to perform a Sonar Cloud validation in my code using Bitbucket pipeline, but I’m getting the error message bellow:

19:28:05.203 DEBUG: 'env/lib/python3.6/site-packages/pandas/tests/scalar/period/test_asfreq.py' generated metadata with charset 'UTF-8'
/usr/bin/run-scanner.sh: line 24:    11 Killed                  sonar-scanner "${ALL_ARGS[@]}" 2>&1
        12 Done                    | tee "${SCANNER_REPORT}"
e[31m SonarCloud analysis failed.e[0m

I tried to increase docker and step memory using the size: 2x and using parameter SONAR_SCANNER_OPTS="-Xmx2048m", but I still receive the same error message.

Please, could you help me?

I’m using the following script in bitbucket-pipelines.yml:

image: python:3.7.2 # Choose an image matching your project needs

clone:
      depth: full              # SonarCloud scanner needs the full history to assign issues properly

definitions:
      services:
        docker:
          memory: 2048
      caches:
            sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
      steps:
      - step: &build-test-sonarcloud
              name: Build, test and analyze on SonarCloud
              size: 2x
              caches:
              -            # See https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html
              - sonar
              script:
              -            # Build your project and run
              - pipe: sonarsource/sonarcloud-scan:1.2.0
                variables:
                  DEBUG: 'true'
      - step: &check-quality-gate-sonarcloud
              name: Check the Quality Gate on SonarCloud
              size: 2x
              script:
              - pipe: sonarsource/sonarcloud-quality-gate:0.1.3
                variables:
                  DEBUG: 'true'

pipelines:                 # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
  branches:
    master:
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud
  pull-requests:
    '**':
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud

Full Log with Debug: pipelineLog-7.txt (3.9 MB)

  • ALM: Bitbucket Cloud
  • CI system: Bitbucket Cloud
  • Languages: Python
  • Potential workaround: Increase memory (it didn’t work)

Thank You!

Hi, sorry for the late reply.

This looks like a good measure, but I don’t see this neither in your pipeline nor in the log output. Can you share how you set this in the pipeline, and the corresponding log output?

A small note: I see you used size: 2x for the check-quality-gate-sonarcloud step too, this is unnecessary. This step is very light-weight, a low-spec machine will be perfectly enough for this.

Hi @janos
Thank you for reply.

I configured this parameter in Bitbucket Interface:

Is there another way to set it?

Thank you again!

Yes! What you tried doesn’t work the way you think. In general, the variables defined in the pipe configuration can be referenced in the bitbucket-pipelines.yml file. These variables are normally not passed directly to the pipe.

To pass that value to the pipe, you need to write the variables section like this in the bitbucket-pipelines.yml file:

  variables:
    DEBUG: 'true'
    SONAR_SCANNER_OPTS: ${SONAR_SCANNER_OPTS}
    # or the value directly: SONAR_SCANNER_OPTS: -Xmx2048m

A post was split to a new topic: Sonar-scanner killed when analyzing large .sql file with 100k+ LOC