英文:
How to install Java 11 through Jenkins Scripted pipeline?
问题
我想使用Jenkins的脚本流程安装Java 11,我已经尝试了以下方式:
node('MySlaves'){
stage('TestStage'){
println "ALm Exporter Started"
tool name: '11.0.12', type: 'jdk'
}
}
node('MySlaves'){
environment {
JAVA_HOME = tool name: '11.0.12', type: 'jdk'
}
}
tools {
jdk '11.0.12'
}
以上三种方法都没有帮助,如果我使用 println "JAVA_HOME set : "+env.JAVA_HOME
,那么我得到的是JDK1.8的值。请问有谁能告诉我如何在脚本流程中安装Java 11(它存在于自定义工具中)?
英文:
I want to install Java 11 using scripted pipeline of Jenkins, and I have tried the below ways
node('MySlaves'){
stage('TestStage'){
println "ALm Exporter Started"
tool name: '11.0.12', type: 'jdk'
}
}
node('MySlaves'){
environment {
JAVA_HOME = tool name: '11.0.12', type: 'jdk'
}
tools {
jdk '11.0.12'
}
All the above 3 methods didn't help and if I use println "JAVA_HOME set : "+env.JAVA_HOME
then I am getting the value of JDK1.8. Can someone let me know how can I install Java 11 (It is present in Custom tool) in Scripted pipeline ?
答案1
得分: 0
这个 显示了如何执行它:
node {
jdk = tool name: 'JDK17'
env.JAVA_HOME = "${jdk}"
echo "jdk 安装路径是: ${jdk}"
[...]
}
英文:
This shows how to do it:
node {
jdk = tool name: 'JDK17'
env.JAVA_HOME = "${jdk}"
echo "jdk installation path is: ${jdk}"
[...]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论