diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java index 1db91948e6..311a04be36 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java @@ -124,6 +124,8 @@ public class PodTemplate extends AbstractDescribableImpl implements private String serviceAccount; + private String schedulerName; + private String nodeSelector; private Node.Mode nodeUsageMode; @@ -567,6 +569,15 @@ public void setServiceAccount(String serviceAccount) { this.serviceAccount = Util.fixEmpty(serviceAccount); } + public String getSchedulerName() { + return schedulerName; + } + + @DataBoundSetter + public void setSchedulerName(String schedulerName) { + this.schedulerName = Util.fixEmpty(schedulerName); + } + @Deprecated @DataBoundSetter public void setAlwaysPullImage(boolean alwaysPullImage) { @@ -1018,6 +1029,7 @@ public String toString() { (activeDeadlineSeconds == 0 ? "" : ", activeDeadlineSeconds=" + activeDeadlineSeconds) + (label == null ? "" : ", label='" + label + '\'') + (serviceAccount == null ? "" : ", serviceAccount='" + serviceAccount + '\'') + + (schedulerName == null ? "" : ", schedulerName='" + schedulerName + '\'') + (nodeSelector == null ? "" : ", nodeSelector='" + nodeSelector + '\'') + (nodeUsageMode == null ? "" : ", nodeUsageMode=" + nodeUsageMode) + (resourceRequestCpu == null ? "" : ", resourceRequestCpu='" + resourceRequestCpu + '\'') + diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilder.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilder.java index 598ef5fbd4..fafadec3d0 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilder.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilder.java @@ -215,6 +215,9 @@ public Pod build() { if (template.getServiceAccount() != null) { builder.withServiceAccountName(substituteEnv(template.getServiceAccount())); } + if (template.getSchedulerName() != null) { + builder.withSchedulerName(substituteEnv(template.getSchedulerName())); + } List imagePullSecrets = template.getImagePullSecrets().stream() .map((x) -> x.toLocalObjectReference()).collect(Collectors.toList()); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtils.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtils.java index 4da7f7505b..44cbd62be8 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtils.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtils.java @@ -250,6 +250,9 @@ public static Pod combine(Pod parent, Pod template) { String serviceAccountName = Strings.isNullOrEmpty(template.getSpec().getServiceAccountName()) ? parent.getSpec().getServiceAccountName() : template.getSpec().getServiceAccountName(); + String schedulerName = Strings.isNullOrEmpty(template.getSpec().getSchedulerName()) + ? parent.getSpec().getSchedulerName() + : template.getSpec().getSchedulerName(); Boolean hostNetwork = template.getSpec().getHostNetwork() != null ? template.getSpec().getHostNetwork() @@ -298,6 +301,7 @@ public static Pod combine(Pod parent, Pod template) { .withNodeSelector(nodeSelector) // .withServiceAccount(serviceAccount) // .withServiceAccountName(serviceAccountName) // + .withSchedulerName(schedulerName) .withHostNetwork(hostNetwork) // .withContainers(combinedContainers) // .withInitContainers(combinedInitContainers) // @@ -371,6 +375,7 @@ public static PodTemplate combine(PodTemplate parent, PodTemplate template) { String label = template.getLabel(); String nodeSelector = Strings.isNullOrEmpty(template.getNodeSelector()) ? parent.getNodeSelector() : template.getNodeSelector(); String serviceAccount = Strings.isNullOrEmpty(template.getServiceAccount()) ? parent.getServiceAccount() : template.getServiceAccount(); + String schedulerName = Strings.isNullOrEmpty(template.getSchedulerName()) ? parent.getSchedulerName() : template.getSchedulerName(); Node.Mode nodeUsageMode = template.getNodeUsageMode() == null ? parent.getNodeUsageMode() : template.getNodeUsageMode(); Set podAnnotations = new LinkedHashSet<>(); @@ -406,6 +411,7 @@ public static PodTemplate combine(PodTemplate parent, PodTemplate template) { podTemplate.setLabel(label); podTemplate.setNodeSelector(nodeSelector); podTemplate.setServiceAccount(serviceAccount); + podTemplate.setSchedulerName(schedulerName); podTemplate.setEnvVars(combineEnvVars(parent, template)); podTemplate.setContainers(new ArrayList<>(combinedContainers.values())); podTemplate.setWorkspaceVolume(workspaceVolume); @@ -434,6 +440,9 @@ public static PodTemplate combine(PodTemplate parent, PodTemplate template) { podTemplate.setServiceAccount(!Strings.isNullOrEmpty(template.getServiceAccount()) ? template.getServiceAccount() : parent.getServiceAccount()); + podTemplate.setSchedulerName(!Strings.isNullOrEmpty(template.getSchedulerName()) ? + template.getSchedulerName() : parent.getSchedulerName()); + podTemplate.setPodRetention(template.getPodRetention()); podTemplate.setShowRawYaml(template.isShowRawYamlSet() ? template.isShowRawYaml() : parent.isShowRawYaml()); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent.java index e42feabd8d..77c8a1ab92 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent.java @@ -53,6 +53,8 @@ public class KubernetesDeclarativeAgent extends DeclarativeAgent