Complete the code to set the JDK version in Jenkins pipeline.
pipeline {
agent any
tools {
jdk '[1]'
}
stages {
stage('Build') {
steps {
echo 'Building with JDK'
}
}
}
}The correct JDK version to set here is JDK11, which is commonly used and supported in Jenkins pipelines.
Complete the code to define a JDK tool in Jenkins global configuration using Groovy script.
import jenkins.model.* import hudson.tools.* Jenkins.instance.getDescriptorByType(hudson.tools.JDK.DescriptorImpl.class).setInstallations( new JDK('[1]', null) ) Jenkins.instance.save()
The JDK name must match the configured tool name. JDK11 is a typical name used for JDK 11 installations.
Fix the error in the Jenkins pipeline snippet to use the JDK tool correctly.
pipeline {
agent any
tools {
jdk '[1]'
}
stages {
stage('Test') {
steps {
sh 'java -version'
}
}
}
}The JDK tool name is case-sensitive and must match exactly the configured name, which is JDK11.
Fill both blanks to configure a JDK tool and use it in a Jenkins pipeline.
pipeline {
agent any
tools {
jdk '[1]'
}
stages {
stage('Compile') {
steps {
sh '[2] -version'
}
}
}
}The JDK tool name is JDK11, and the command to check the version is java.
Fill all three blanks to define a JDK tool, set it in the pipeline, and run a build command.
pipeline {
agent any
tools {
jdk '[1]'
}
stages {
stage('Build') {
steps {
sh '[2] [3]'
}
}
}
}The JDK tool is JDK11. The command to check the version is java -version. mvn is unrelated here.