英文:
Jenkins and Java 14, how to properly select the JDK compiler for a given job?
问题
我发现了一些与此相关的主题,但在Java 14和最近的Jenkins版本方面没有新的内容。推荐的步骤是什么,以使Java 14在Jenkins中作为通过作业编译Java项目的选项可用?
在我的当前安装中,我找不到配置JDK
选项,也没有任何下拉菜单可以在某个地方选择它。关于推荐的几种不同方法,我也有些困惑。
英文:
I've found few topics related to this, but nothing new in terms of Java 14 and recent Jenkins versions. What are the recommended steps to make Java 14 available in Jenkins as an option to compile Java projects through jobs?
In my current installation, I cannot find the Configure JDK
option nor any drop-down to pick it up somewhere. I'm also a bit confused with several different ways that are recommeded to do that.
答案1
得分: 0
要使用不同的Java版本,您需要在主Jenkins配置菜单中进行配置:`“管理Jenkins”->“全局工具配置”->“添加JDK”`。您可以自动或手动安装一些版本,但是:
“Oracle Java SE 11+在没有商业许可的情况下不适用于商业、商业或生产用途。自2019年1月后发布的Oracle Java SE 8的公共更新,在没有商业许可的情况下不适用于商业、商业或生产用途。”
然后,您将能够将其添加到作业中。例如,在声明性流水线中使用“工具”步骤:
流水线{
代理任何
工具{
nodejs 'java_8'
}
阶段{
阶段('java测试'){
步骤{
sh 'java -version'
}
}
}
}
英文:
To use different java versions you need to configure it in main jenkins config menu "Manage jenkins" -> "Global tool configuration" -> "Add JDK"
. You can install some versions automatically or manually, but:
"Oracle Java SE 11+ is not available for business, commercial or production use without a commercial license. Public updates for Oracle Java SE 8 released after January 2019 will not be available for business, commercial or production use without a commercial license."
After then you will be able to add it into your job. For example use "tool" step in declarative pipeline:
pipeline {
agent any
tools {
nodejs 'java_8'
}
stages {
stage ('java test') {
steps {
sh 'java -version'
}
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论