Our Jenkins builds started failing overnight with the error:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7:sonar (default-cli) on project <project>:
Execution default-cli of goal org.codehaus.mojo:sonar-maven-plugin:2.7:sonar failed:
Unable to load the mojo 'sonar' in the plugin 'org.codehaus.mojo:sonar-maven-plugin:2.7' due to an API incompatibility:
org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/codehaus/mojo/sonar/SonarMojo :
Unsupported major.minor version 51.0
The Jenkins server is still running Java 6, but we did not change anything.
What happened and how do we fix it?
The jenkins-sonar-plugin uses sonar-maven-plugin to run the Sonar analysis.
Sonar-maven-plugin was updated to 2.7 on 2015-10-19 and the new version is not compatible with Java 6.
Jenkins-sonar-plugin uses the latest version of sonar-maven-plugin per default, but you can override this.
So to fix the error, open "Manage Jenkins"/"Configure System", find the Sonar section, click advanced and enter 2.6 in "Version of sonar-maven-plugin". This forces jenkins-sonar-plugin to use the previous version of sonar-maven-plugin, which works with Java 6.
Alternatively, if you want to set 2.6 only for one specific Jenkins job then you can force maven to use 2.6 version using goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
instead of standard sonar:sonar
.
Also: begin planning to upgrade the build server to Java 7 or Java 8.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With