Jenkins Sonar plugin suddenly stops working

匿名 (未验证) 提交于 2019-12-03 03:06:01

问题:

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?

回答1:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!