Adds a build parameter that allows selecting a configured JDK installation for each build.
This plugin adds a build parameter that allows setting which JDK should be used for a job on a per-build basis.
The JDKs available for selection can be configured on the job configuration page when the JDK parameter is enabled.
- Go to Manage Jenkins → Global Tool Configuration
- Configure one or more JDK installations
- Save the configuration
To use in a job:
- Open the job configuration page
- Enable This build is parameterized
- Add parameter → Select JDK Parameter
- Choose the default JDK and allowed JDK selections
On the build parameters page, a dropdown list allows selecting which configured JDK should be used for that build.
pipeline {
agent any
parameters {
jdk(name: 'JDK17')
}
stages {
stage('Check Java Version') {
steps {
sh 'java -version'
}
}
}
}