在Jenkins中使用OpenJDK 14 [英] Using OpenJDK 14 in Jenkins
问题描述
是否可以在Jenkins(Docker版本)中使用OpenJDK-14? 我通过从以下链接解压缩JDK在配置"中设置版本: https://download.java.net/openjdk/jdk14/ri/openjdk-14 + 36_linux-x64_bin.tar.gz
Is it possible to use OpenJDK-14 in Jenkins (Docker version)? I set the version in the Configurations by unpacking the JDK from this link: https://download.java.net/openjdk/jdk14/ri/openjdk-14+36_linux-x64_bin.tar.gz
这是我的Jenkins文件:
pipeline {
agent any
tools {
jdk 'jdk-14'
maven 'Maven-3-6-3'
}
stages {
stage("build project") {
steps {
sh 'java -version'
echo 'building project...'
sh 'mvn clean install'
}
}
}
}
这是我得到的错误:
-
mvn clean install
JAVA_HOME环境变量未正确定义 运行该程序需要此环境变量 注意:JAVA_HOME应该指向JDK而不是JRE
mvn clean install
The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE
也可以使用sh'java -version'命令给我以下信息:
-
java -version
openjdk版本"1.8.0_242" OpenJDK运行时环境(内部版本1.8.0_242-b08) OpenJDK 64位服务器VM(内部版本25.242-b08,混合模式)
java -version
openjdk version "1.8.0_242" OpenJDK Runtime Environment (build 1.8.0_242-b08) OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
推荐答案
通常,您可以安装" Jenkins AdoptOpenJDK安装程序插件"
Generally, you can install the "Jenkins AdoptOpenJDK installer Plugin"
然后在全局工具配置|添加JDK (${JENKINSURL}/configureTools/
),您将
- 添加JDK
- 勾选自动安装
- 删除安装程序(从而删除默认的Oracle安装程序)
- 添加安装程序
- 从takeOpenJDK.net安装
- 保存
如果您安装了多个JDK,则在您的作业中,您现在应该可以选择JDK或在
If you have more than one JDK installed, in your jobs, you should now have an option to choose JDK or specify in the pipeline tools section.
或者,您可以仅指定预先安装JDK14的路径,而不是动态安装.
Alternatively, you can just specify the path to where JDK14 is installed beforehand instead of dynamically installing.
似乎您已经预先安装"了部分完成,但是缺少全局工具配置,为jdk-14
设置了路径,因此它不会覆盖SYSTEM默认值.
It would seem you have the "installed beforehand" part done, but are missing the Global tool configuration, setting the path for jdk-14
, so it's not overriding the SYSTEM default.
(显然,是从下拉菜单中选择或设置路径).
这篇关于在Jenkins中使用OpenJDK 14的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!