A maven plugin that will fail a maven build if sonar reports errors with your project. Tested with SonarQube 5.2 through 6.2.
To include in your project, update your pom.xml with the following:
<dependencies>
<dependency>
<groupId>com.github.sgoertzen</groupId>
<artifactId>sonarbreak</artifactId>
<version>1.2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.sgoertzen</groupId>
<artifactId>sonarbreak</artifactId>
<version>1.2.2</version>
<configuration>
<sonarServer>https://sonar.yourserver.com</sonarServer>
</configuration>
</plugin>
</plugins>
</build>
There are two optional parameters that can be used with this plugin.
These parameter goes into the configuration section so the build piece of your pom.xml would look like:
<build>
<plugins>
<plugin>
<groupId>com.github.sgoertzen</groupId>
<artifactId>sonarbreak</artifactId>
<version>1.2.2</version>
<configuration>
<sonarServer>https://sonar.yourserver.com</sonarServer>
<sonarLookBackSeconds>60</sonarLookBackSeconds>
<waitForProcessingSeconds>600</waitForProcessingSeconds>
</configuration>
</plugin>
</plugins>
</build>
You must also have the sonar plugin installed:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.7.1</version>
</plugin>
Then run maven using the command:
mvn sonar:sonar sonar-break:sonar-break
Details:
An full working pom.xml example can be seen in the integration-tests folder here: https://github.com/sgoertzen/sonar-break-maven-plugin/blob/master/integration-tests/basic/pom.xml
The plugin is hosted on SonaType Nexus with the full history shown here
You can build and run the tests
mvn clean package
mvn clean install exec:exec -Dmaven.signing.skip=true
Integration Test Details:
If you run "mvn verify" or "mvn install" it will attempt to sign the output using gpg. Just pass "-Dmaven.signing.skip=true" into maven to skip this plugin. Example: "mvn clean install exec:exec -Dmaven.signing.skip=true"