JENKINS:当我尝试将较旧的JDK用于特定的Maven项目时出现错误 [英] JENKINS: ERROR when I try to use an older JDK for a specific maven project
问题描述
我正在CentOS Linux版本7.3.1611服务器上使用Jenkins版本2.73-1.1.
服务器上有3种不同的JDK版本:
[root @ jenkins java] # ll
total 12
lrwxrwxrwx. 1 root root 16 27 Apr 16.25 default -> / usr / java / latest
drwxr-xr-x. 8 root root 4096 27 Mar 2013 jdk1.6.0_45
drwxr-xr-x. Root root 4096 11 Apr 2015 jdk1.7.0_80
drwxr-xr-x. 9 root root 4096 27 Apr 16.25 jdk1.8.0_131
lrwxrwxrwx. 1 root root 22 27 apr 16.25 latest -> /usr/java/jdk1.8.0_131
如下图所示,Jenkins使用的是jdk1.8.0_131版本,在我的项目中,我指定使用JDK7.
当我尝试编译项目(mvn clean deploy
)时,构建失败,并且在日志中看到此错误:
[Vodafone] $/usr/java/jdk1.7.0_80/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.11.jar:/opt/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main/opt/apache-maven-3.0.4 /var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.11.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar 46349< === [詹金斯移除容量] ===>频道已启动错误: ================================================== ============================错误:无效的项目设置:jenkins/security/MasterToSlaveCallable: 不支持的major.minor版本52.0错误: [JENKINS-18403] [JENKINS-28294] JDK'JAVA7'不支持运行Maven 项目.错误:必须使用Java启动Maven项目 版本大于或等于版本要求的最低版本 掌握.错误:使用Maven JDK工具链(插件)来构建您的 带有较旧JDK的Maven项目.错误:尝试使用从属Java和 将编译/测试属性设置为指向/usr/java/jdk1.7.0_80. 错误: ================================================== =============================在38129 [Vodafone] $上建立了TCP套接字 /usr/java/jdk1.8.0_131/jre/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.11.jar:/opt/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main/opt/apache-maven-3.0.4 /var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.11.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar 38129< === [詹金斯移除容量] ===>频道已启动
为什么詹金斯不使用jdk 7?
jenkins主页的rel ="nofollow noreferrer"> Maven项目插件: Jenkins> = 2.54需要Java 8,因此必须使用Java> = 8启动Maven作业 幸运的是,您的堆栈跟踪中仅提到了最佳的解决方法: ...使用 Maven JDK工具链(插件),使用较旧的JDK构建您的maven项目... 为了使用Java 7编译项目并使用当前的jenkins版本启动成功的jenkins作业,我建议您使用Jenkins setup Image 1 When I try to compile my project ( [Vodafone] $ /usr/java/jdk1.7.0_80/bin/java -cp
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.11.jar:/opt/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar
org.jvnet.hudson.maven3.agent.Maven3Main /opt/apache-maven-3.0.4
/var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.jar
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.11.jar
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar
46349 <===[JENKINS REMOTING CAPACITY]===>channel started ERROR:
================================================================================ ERROR: Invalid project setup: jenkins/security/MasterToSlaveCallable :
Unsupported major.minor version 52.0 ERROR:
[JENKINS-18403][JENKINS-28294] JDK 'JAVA7' not supported to run Maven
projects. ERROR: Maven projects have to be launched with a Java
version greater or equal to the minimum version required by the
master. ERROR: Use the Maven JDK Toolchains (plugin) to build your
maven project with an older JDK. ERROR: Retrying with slave Java and
setting compile/test properties to point to /usr/java/jdk1.7.0_80.
ERROR:
================================================================================ Established TCP socket on 38129 [Vodafone] $
/usr/java/jdk1.8.0_131/jre/bin/java -cp
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.11.jar:/opt/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar
org.jvnet.hudson.maven3.agent.Maven3Main /opt/apache-maven-3.0.4
/var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.jar
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.11.jar
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar
38129 <===[JENKINS REMOTING CAPACITY]===>channel started Why Jenkins doesn't use jdk 7? As it is documented on the maven project plugin of jenkins home page: Jenkins >= 2.54 requires Java 8 thus Maven jobs must be launched with Java >= 8 Luckily the best workaround is just mentioned in your stacktrace: ... Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK... In order to compile your project using java 7 and launching successful jenkins job using current jenkins version, I would recommend you to use this plugin by 2 simple steps: Add toolchains.xml file to your .m2 directory both on developers system and jenkins server Add toolchain plugin to your project pom file Finally config your jenkins job to use jdk 8, toolchain will take care of compiling your project with jdk 7. 这篇关于JENKINS:当我尝试将较旧的JDK用于特定的Maven项目时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
mvn clean deploy
), the build fails and I see this ERROR in log:
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.7</version>
<vendor>openjdk</vendor>
</provides>
<configuration>
<jdkHome>/usr/lib/jvm/java-7-openjdk-amd64</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
<vendor>openjdk</vendor>
</provides>
<configuration>
<jdkHome>/usr/lib/jvm/java-8-openjdk-amd64</jdkHome>
</configuration>
</toolchain>
[...]
</toolchains>
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.7</version>
<vendor>openjdk</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
</build>
</project>