Jenkins Sonar plugin suddenly stops working

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?

  • How can I execute Shell script in Jenkins?
  • Jenkins - conditions between build steps
  • jenkins complains host key verification failure although the key was generated
  • Jenkins executing maven from incorrect path
  • What is the effect on @NonCPS in a Jenkins pipeline script
  • hudson/jenkins keeps building the bad branch in git instead of the good one
  • One Solution collect form web for “Jenkins Sonar plugin suddenly stops working”

    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.

    Git Baby is a git and github fan, let's start git clone.