5

Earlier I use sonar-maven-plugin version 3.2 then when a Sonar quality gate fails the build also used to fail. Now I am using sonar-maven-plugin version 3.7.0.1746, it does not happen so. Even if quality gate fails maven build succeeded. Now when I use version 3.2 in pom.xml it gives the error

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project maven-webapp: Unable to execute SonarQube: Fail to download libraries from server -> [Help 1]

While using sonar-maven-plugin version 3.7.0.1746 doesn't give the above error.

This is how I add the plugin in Pom.xml

<plugin>
     <groupId>org.sonarsource.scanner.maven</groupId>
     <artifactId>sonar-maven-plugin</artifactId>
     <version>3.2</version>
</plugin>

I also got to know that in version 3.2 there was some post-job action like org.sonar.plugins.buildbreaker.QualityGateBreaker.

How can it be done now? I am using https://sonarcloud.io/ for sonar.

Shivansh Kumar
  • 321
  • 1
  • 5
  • 16
  • If you find a solution please let us know. – Anand Varkey Philips Aug 11 '20 at 10:44
  • I'd guess it was a design change. At least it looks like they changed Jenkins integration features because fundamental changes in SonarQube that made it a bad pattern to use. See: https://blog.sonarsource.com/why-you-shouldnt-use-build-breaker/ Also, they (re)introduced a different implementation for Jenkins pipelines: https://blog.sonarsource.com/breaking-the-sonarqube-analysis-with-jenkins-pipelines/ Still, none of this exactly covers Maven, nor Sonar Cloud. – Attila Csipak Mar 30 '21 at 14:13

1 Answers1

3

If Sonar Qube Server version is bigger than 8.1, sonar.qualitygate.wait=true can be used:

mvn verify sonar:sonar -Dsonar.qualitygate.wait=true

Otherwise, there is a maven plugin to detect Sonar Quality Gate Result:

 <plugin>
        <groupId>io.github.r0bb3n</groupId>
        <artifactId>sonar-quality-gate-maven-plugin</artifactId>
        <version>1.1.0</version>
  </plugin>

Then, you will run the following Maven Command:

mvn sonar-quality-gate:check
kaan bobac
  • 729
  • 4
  • 8