Run Sonar analysis with Gitlab CI/CD is very slow but in the project root is correct


We use recently Sonar in Gitlab CI/CD and runs Sonar are become very slow.

For example, if I get source code of my project and execute the cmd “mvn verify sonar:sonar “-Dsonar.projectKey=****” “-Dsonar.qualitygate.wait=true”” directly on the project root, it’s take 1m20. If I execute the same command on the pipeline gitlab, it’s take 4m30…

In first time, I thought that the problem is due to cache, so i disabled it in the gitlab-ci.yml. But after an other run in gitlab, the time of pipeline is 3m. I don’t think this method is good.

For info, gitlab runners and SonarQube Server are on the same VM.


    GIT_DEPTH: "0"
    key: "${CI_JOB_NAME}"
      - .sonar/cache
    - mvn verify sonar:sonar "-Dsonar.projectKey=****" "-Dsonar.qualitygate.wait=true"
  allow_failure: true
    - merge_requests
    - master
    - develop
    - release

I added properties like ARTIFACT_COMPRESSION_LEVEL: “fast” and CACHE_COMPRESSION_LEVEL: “fastest” but I don’t have seen a good result.

We use Gitlab 14.3.2, GItlab runner 12.4.1 and SonarQube Entreprise 8.9.2.

Do you have any idea of the problem ?

Thanks for your help.


What’s the environment (memory, processor speed, load, &etc) on your localhost versus the GitLab build agent?



The VM of SonarQube/GitlabRunners :

  • Speed processor 2,00 GHz
  • Intel(R) Xeon(R) CPU E5-2660 v4
  • 4 threads
  • Memory 16 Gb
  • JDK 11

CPU speed reaches 99% when sonar or other java is running.

I can see the hardware requirements here : Prerequisites and Overview | SonarQube Docs

Should I allocate at least 8 cores for the CPU? And the speed processor, 2Ghz is correct ?

Gitlab is on a Linux machine, I don’t know the configurations.

Thanks for your help.


You’re making a comparison between performance on your GitLab agents versus on your localhost, so I was really asking about the configuration difference between the two, not necessarily what your build agent configuration is.

And going back to your OP, you mentioned analysis slowing down. Can you correlate the slowdown to anything? An upgrade to SonarQube? The build agent OS? GitLab? Is it possible the build agents just need a file space clean out?