From 928c5ef0ee5b3dd7ae08936a99bbe9278a1ebf73 Mon Sep 17 00:00:00 2001 From: Austin Moore Date: Wed, 15 Feb 2017 13:55:40 -0500 Subject: [PATCH] Make the name field in the pod template the pod's name --- .../jenkins/plugins/kubernetes/pipeline/PodTemplateStep.java | 2 +- .../kubernetes/pipeline/PodTemplateStepExecution.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep.java index fdfa6dd00a..8c26bb88d6 100755 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep.java @@ -47,7 +47,7 @@ public class PodTemplateStep extends Step implements Serializable { @DataBoundConstructor public PodTemplateStep(String label, String name) { this.label = label; - this.name = name; + this.name = name == null ? "kubernetes" : name; } public String getLabel() { diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java index b74e54d46a..10daddf6cc 100755 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java @@ -23,7 +23,7 @@ public class PodTemplateStepExecution extends AbstractStepExecutionImpl { private static final long serialVersionUID = -6139090518333729333L; - private static final transient String NAME_FORMAT = "kubernetes-%s"; + private static final transient String NAME_FORMAT = "%s-%s"; private final PodTemplateStep step; @@ -44,7 +44,8 @@ public boolean start() throws Exception { cloud.getClass().getName())); } KubernetesCloud kubernetesCloud = (KubernetesCloud) cloud; - String name = String.format(NAME_FORMAT, UUID.randomUUID().toString().replaceAll("-", "")); + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + String name = String.format(NAME_FORMAT, step.getName(), uuid); PodTemplateAction action = new PodTemplateAction(getContext().get(Run.class));