Search code examples
sonarqubegitlab-cisonarqube-scan

gitlab CI: Quality Gate check timeout exceeded


I keep getting this message in my pipeline:

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project com.my-app: Quality Gate check timeout exceeded

enter image description here

This is the configuration used in gitlab-ci.yml file:

sonar:
  stage: report
  needs:
    - build
  image: maven:3.8.6-amazoncorretto-17
  tags:
    - my-runner
  allow_failure: true
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
    SONAR_TOKEN: "my-token"
    SONAR_HOST_URL: "https://sonar-server/"
    GIT_DEPTH: 0
  cache:
    <<: *maven_cache
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: always   
  script:
    - mvn clean package
    - mvn -gs ../pom.xml sonar:sonar -Dsonar.qualitygate.wait=true -Dsonar.java.binaries=./target/classes

any thoughts what the problem might be?


Solution

  • During the setup of Sonarqube for a mainly Java-based Multi-Module Project with ~800k Lines of code, I ran into the same issue, except we did not have Gitlab at that time.

    Steps that solved the issue in my case:

    • in sonarqube-9.8.XXXX\conf\sonar.properties increase the Xmx setting: sonar.web.javaOpts=-Xmx4096m -Xms128m -XX:+HeapDumpOnOutOfMemoryError

    • in sonarqube-9.8.XXXX\bin\windows-x86-64\StartSonar.bat add these entries to the java call:

      -Dsonar.qualitygate.wait=true

      -Dsonar.qualitygate.timeout=2000

    That was basically C&P from https://github.com/cloud-native-toolkit/planning/issues/610 ;)