I have a regular Jenkins instance running with some multibranch pipelines. The instance runs on JDK 11, as higher versions are not really supported with Jenkins. That's alright.
What is not alright though, is that all my pipelines also seem to be capped to Java 11 by that. Jenkins just runs all the builds with the JDK it uses itself too. That is not alright, though.
At this point, any solution would do, but ideally I would just like to have two seperate JDKs: JDK 11, for Jenkins itself and another JDK it automatically runs all builds on.
Is there any way to achieve this? Thanks in advance - Emil
You can use the desired JDK with a docker agent. With this, you can defined an image which use the appropriate JDK or any image.
For example, in your case, you can have the JDK 11 for jenkins itself and the one you want in each job. Example with openjdk :
pipeline {
agent {
docker { image 'openjdk:11' }
}
stages {
stage('Test java version') {
steps {
sh 'java -version'
}
}
}
}
You can choose the tag you want to select the appropriate version.
You just need to setup docker in your jenkins instance.