Skip to content

Commit 75922df

Browse files
committed
Add optional ID to the pod template step class such that it can be supplied by dynamic groovy and then applied if present in the step execution, thus leaving functionality unchanged for existing use cases such as manually configuring pod templates in a Jenkins UI.
1 parent 9cb5674 commit 75922df

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public class PodTemplateStep extends Step implements Serializable {
5555
@CheckForNull
5656
private String name;
5757

58+
private String id;
59+
5860
@CheckForNull
5961
private String namespace;
6062

@@ -119,11 +121,20 @@ public void setLabel(@CheckForNull String label) {
119121
this.label = Util.fixEmpty(label);
120122
}
121123

124+
@DataBoundSetter
125+
public void setId(String id) {
126+
this.id = Util.fixEmpty(id);
127+
}
128+
122129
@CheckForNull
123130
public String getName() {
124131
return name;
125132
}
126133

134+
public String getId() {
135+
return id;
136+
}
137+
127138
@DataBoundSetter
128139
public void setName(@CheckForNull String name) {
129140
this.name = Util.fixEmpty(name);

src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ public boolean start() throws Exception {
8585
String name = String.format(NAME_FORMAT, stepName, randString);
8686
String namespace = checkNamespace(cloud, podTemplateContext);
8787

88-
newTemplate = new PodTemplate();
88+
if (step.getId() != null) {
89+
newTemplate = new PodTemplate(step.getId());
90+
} else {
91+
newTemplate = new PodTemplate();
92+
}
93+
8994
newTemplate.setName(name);
9095
newTemplate.setNamespace(namespace);
9196

0 commit comments

Comments
 (0)