Sonar Quality Gates Maven Plugin

Description

This plugin will break the maven build if the project fails the quality gate. These checks should happen after analysis has been submitted to the server.

Recommend using [https://github.com/adnovum/sonar-build-breaker], easier to integrate with sonarqube.

Origin

Fork of https://github.com/slam-it/sonar-quality-gates-maven-plugin, added support for sonarqube 7.9.x, migrated package to com.hack23.maven released to maven central.

Badges

license Maven Central Jenkins Jenkins tests Coverage Lines of Code Technical Debt Quality Gate Black Duck Security Risk FOSSA Status

Runtime

[JDK-8] [JDK-11 or higher] [JDK-12] [JDK-13]

Usage

$ mvn sonar-quality-gates:inspect

Configuration

  • sonarHostUrl
  • The Sonar host url
  • Default: http://localhost:9000

Note: sonarHostUrl property is optional and will be inferred from the sonar.host.url property (in the pom.xml or as a property in a [settings.xml profile](#Example Sonar profile (settings.xml)) if not specified

Example

<build>
  <plugins>
    <plugin>
      <groupId>com.hack23.maven</groupId>
      <artifactId>sonar-quality-gates-maven-plugin</artifactId>
      <version>1.0-SNAPSHOT</version>
      <!-- Optional configuration -->
      <configuration>
        <sonarHostUrl>SONAR-HOST-URL</sonarHostUrl>
        <sonarLogin>(username ore token)</sonarLogin>
        <sonarPassword>(password if username used, not when using token)</sonarPassword>
      </configuration>
    </plugin>
  </plugins>
</build>

Example Sonar profile (settings.xml)

<profile>
  <id>sonar</id>
  <properties>
    <sonar.host.url>http://localhost:9000</sonar.host.url>
    <sonar.login>(username ore token)</sonar.login>
    <sonar.password>(password if username used, not when using token)</sonar.password>
  </properties>
</profile>

<activeProfiles>
  <activeProfile>sonar</activeProfile>
</activeProfiles>