0

I tried to connect sonarcloud with bitbucket pipeline, but i continue to get this error

Container 'docker' exceeded memory limit.

I tried to increase memory up to 4096 but with this value i get this error

The Build, test and analyze on SonarCloud step doesn’t have enough memory to run. It is a 1x size step with 4096MB of memory, and 4096MB is allocated to defined step services. 1024MB is required to run the step scripts. You will need to reduce the memory requirements of the services on the step by 1024MB.

this is my yalm file

clone:
  depth: full              # SonarCloud scanner needs the full history to assign issues properly
definitions:
  services:
    docker:
        memory: 3072
  caches:
    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
  steps:
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
        caches:
          - sonar
        script:       # Build your project and run
          - pipe: sonarsource/sonarcloud-scan:1.4.0
    - step: &check-quality-gate-sonarcloud
        name: Check the Quality Gate on SonarCloud
        script:
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.6

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

How can i fix this?

Luca Nitti
  • 67
  • 8

1 Answers1

0

If you need more than 3072 MB of memory for a service then you should provision a size: 2x for all steps using that service.

If that service is docker, that means all steps using a pipe.

Note you will be charged twice.

definitions:
  services:
    docker:
        memory: 7168

  yaml-anchors:
    - &my-step
        name: Something
        size: 2x
        script:
          - pipe: something

pipelines:
  default:
    - step: *my-step

Also note you can define multiple docker services with different memory requirements and wisely use each one in each step.

N1ngu
  • 2,862
  • 17
  • 35
  • but sonarcloud charge for line of code, not for any other setting. Or your comment is referred to a general case? – Luca Nitti Feb 27 '23 at 16:18
  • If using BitBucket Cloud and non-dedicated CI runners, Atlassian will deduct twice the pipeline time of size-2x steps from your monthly execution quota. Nothing to do with whatever service you might be connecting inside your step. – N1ngu Feb 27 '23 at 16:26