Search code examples
bitbucketsonarqube-scanbitbucket-pipelinessonarcloud

How to optimize Bitbucket pipeline for Sonarcloud scan pipe?


Every time Sonarcloud scanner starts, it download the image. It slowing down whole pipeline and generate additional cost.

Poor documentation don't have any information about additional cache https://bitbucket.org/sonarsource/sonarcloud-scan/src/master/

1.1.0: Pulling from sonarsource/sonarcloud-scan
27833a3ba0a5: Pulling fs layer
16d944e3d00d: Pulling fs layer
6aaf465b8930: Pulling fs layer
0684138f4cb6: Pulling fs layer
...
646f14b7521f: Pull complete
94dd58113625: Pull complete
41b91f2908b5: Pull complete

Solution

  • Try to use cache for docker (Docker is used internally in sonarcloud-scan pipe).

    After enabling cache it runs faster by 1 minute

        - step: &sca
              image: atlassian/default-image:2  #quickest image
              name: SonarCube SCA
              caches:
                - docker
              script:
                - pipe: sonarsource/sonarcloud-scan:1.1.0
                - pipe: sonarsource/sonarcloud-quality-gate:0.1.3
              services:
                - docker
    

    More info: https://gist.github.com/GetoXs/e2b323b048aad88c12a10aceba3cc6cd