Quality Gate does not fail the pipeline in CI

SonarQube Server version: 9.9.8.100196 (company instance)
SonarScanner CLI version: 7.1.0.4889
How is SonarQube deployed: Company-managed instance (not self-hosted, details unknown)

Project type:
Symfony PHP project

What are you trying to achieve:
I want my GitLab CI pipeline to fail if the unit test coverage is below the threshold defined by the Quality Gate (“Sonar way” with coverage ≥ 80%).

What have you tried so far:

  • The project is a Symfony PHP app, coverage is about 44%.
  • The pipeline runs PHPUnit with coverage and uploads the clover.xml report.
  • The SonarQube analysis imports the report and shows the correct coverage in the UI.
  • The Quality Gate used is “Sonar way” (default), which should require at least 80% coverage.
  • The pipeline job is configured with allow_failure: false and sonar.qualitygate.wait=true.
  • Despite this, the pipeline passes even when coverage is below 80%.

Problem
I am surprised that the pipeline does not fail when the coverage is insufficient.
Does anyone know why the Quality Gate is not blocking the pipeline as expected?

sonar-project.properties file :

sonar.projectName=xx
sonar.projectVersion=1.0.0
sonar.projectKey=xx
sonar.sources=src
sonar.tests=tests
sonar.sourceEncoding=UTF-8
sonar.language=php
sonar.exclusions=var/,vendor/,public/build/, assets/, tests/bootstrap.php
sonar.coverage.exclusions=tests/**,src/Kernel.php
sonar.php.coverage.reportPaths=var/coverage/clover.xml
sonar.php.tests.reportPath=var/coverage/junit.xml
sonar.links.scm=https://git.xx.fr/etudes/Symfony/xx/xx.git
sonar.host.url=https://xx.tech.xx.fr
sonar.qualitygate.wait=true

.gitlab-ci :
job uni test
script:
- mkdir -p var/coverage
- XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-clover var/coverage/clover.xml --coverage-html var/coverage/html --log-junit var/coverage/junit.xml
- cd var/coverage && zip -r coverage-html.zip html/ && cd ../.. || echo “Zip creation failed but continuing”

Job sonarqube :
script:
- ls -la var/coverage/
- sonar-scanner

Thank you for your help!

Hi,

Welcome to the community!

Your version is past EOL. You should upgrade to either the latest version or the current LTA (long-term active version) at your earliest convenience. Your upgrade path is:

9.9.8 → 2025.1.3 → 2025.3.1 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

Regarding your question…

The Sonar way Quality Gate requires 80% coverage on New code. For what you want, you would need to add an additional condition on Overall code.

 
HTH,
Ann

1 Like

Hi,

Sorry for the late reply, and thank you for your response.

1 Like