Skip to content

Commit

Permalink
Merge pull request #1018 from Inform-Software/use-jdk11-image
Browse files Browse the repository at this point in the history
Use jdk11 agent when Jenkins is running on jdk11
  • Loading branch information
Vlatombe authored Aug 23, 2021
2 parents 8742870 + 502f3cc commit f70e44e
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
import io.fabric8.kubernetes.api.model.VolumeMount;
import io.fabric8.kubernetes.api.model.VolumeMountBuilder;
import io.fabric8.kubernetes.client.utils.Serialization;

import io.jenkins.lib.versionnumber.JavaSpecificationVersion;
import jenkins.model.Jenkins;

import javax.annotation.CheckForNull;
Expand Down Expand Up @@ -103,7 +103,7 @@ public class PodTemplateBuilder {
.getProperty(PodTemplateStepExecution.class.getName() + ".dockerRegistryPrefix");
@Restricted(NoExternalUse.class)
static final String DEFAULT_JNLP_IMAGE = System
.getProperty(PodTemplateStepExecution.class.getName() + ".defaultImage", "jenkins/inbound-agent:4.3-4");
.getProperty(PodTemplateStepExecution.class.getName() + ".defaultImage", getDefaultImageName());

static final String DEFAULT_JNLP_CONTAINER_MEMORY_REQUEST = System
.getProperty(PodTemplateStepExecution.class.getName() + ".defaultContainer.defaultMemoryRequest", "256Mi");
Expand Down Expand Up @@ -137,6 +137,15 @@ public PodTemplateBuilder(PodTemplate template, KubernetesSlave agent) {
this.cloud = agent.getKubernetesCloud();
}

private static String getDefaultImageName() {
// TODO: Reverse logic after inbound-agent:4.9-1
String name = "jenkins/inbound-agent:4.3-4";
if (JavaSpecificationVersion.forCurrentJVM().isNewerThanOrEqualTo(JavaSpecificationVersion.JAVA_11)) {
name = name + "-jdk11";
}
return name;
}

public PodTemplateBuilder withSlave(@Nonnull KubernetesSlave slave) {
this.agent = slave;
this.cloud = slave.getKubernetesCloud();
Expand Down

0 comments on commit f70e44e

Please sign in to comment.