Reputation: 1389
We have a requirement that we need to set the JDK version to 1.8 from 1.7 for all the jobs ran during last 3 months.
import hudson.model.*
import hudson.task.*
for (item in Hudson.instance.allItems){
if(item.name.contains("test")){
if(item.JDK != null){
manager.listener.logger.println("test job are : " + item.name);
manager.listener.logger.println("JDK : " + item.JDK);
manager.listener.logger.println("\n =========== \n");
}
}
}
With the above code, i am able to fethc the JDK version for all the Test jobs, in the below format.
test job are : jacoco_test
JDK : JDK[SUN-JDK-1.7]
============================
test job are :kps-batch-snapshot-test
JDK : JDK[IBM-JDK-8]
but i am not able to set them to IBM-JDK-8.
Thanks in Advance..
Upvotes: 1
Views: 1677
Reputation: 1748
According to the Javadoc, it can be done using setJDK(). Try this:
item.JDK = Jenkins.instance.getJDK('IBM-JDK-8')
Upvotes: 3