Hi all,
I recently took up a task to test code compiled with JDK 8 using Java 11
runtime. In order to do that, I'm trying to use two different JDKs in one
Jenkins job,
which is defined in Job DSL. We don't use Jenkinsfiles in Apache Beam, so
their functionalities are beyond my reach.
So far I was able to do it on a local docker instance of Jenkins by using
two gradle tasks, which both had Java paths explicitly passed to them:

gradle {
  rootBuildScriptDir(commonJobProperties.checkoutDir)
  tasks(':beam-runners-direct-java:shadowJar')
  tasks(':beam-runners-direct-java:shadowTestJar')
  switches('-Dorg.gradle.java.home=\'/var/jenkins_home/jdk1.8.0_202\'')
  commonJobProperties.setGradleSwitches(delegate, 3 *
Runtime.runtime.availableProcessors())
}

like this. The problem is that I don't want to hardcode paths into job
definitions for ASF's Jenkins, as I want the job definition to be protected
from potential changes in JDK installation directories.
Ideally, I'd like to have both JAVA_HOMEs in different env variables, like
JAVA_HOME_8 and JAVA_HOME_11 and just to access them in the job.
What is your take on a solution to this?

Have a great day

-- 

Michał Walenia
Polidea <https://www.polidea.com/> | Software Engineer

M: +48 791 432 002 <+48791432002>
E: michal.wale...@polidea.com

We create human & business stories through technology.
Check out our projects! <https://www.polidea.com/our-work>

Reply via email to