问题描述
我发现与此相关的主题很少,但是就Java 14和最新的Jenkins版本而言,没有什么新鲜的。建议通过哪些步骤使Java 14在Jenkins中可用,以作为通过作业编译Java项目的选择?
在我当前的安装中,找不到Configure JDK
选项,也找不到任何下拉菜单来选择它。我对建议采用的几种不同方式也有些困惑。
解决方法
要使用不同的Java版本,您需要在主詹金斯配置菜单"Manage jenkins" -> "Global tool configuration" -> "Add JDK"
中对其进行配置。您可以自动或手动安装某些版本,但是:
"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."
之后,您将可以将其添加到您的工作中。例如,在声明式管道中使用“工具”步骤:
pipeline {
agent any
tools {
nodejs 'java_8'
}
stages {
stage ('java test') {
steps {
sh 'java -version'
}
}
}
}