From ce73ef57ceb5f0b11694962f875d661d4eec9302 Mon Sep 17 00:00:00 2001 From: Kenneth Rogers Date: Wed, 9 Dec 2020 16:19:00 -0500 Subject: [PATCH] [JENKINS-57841] Change defaults for command and args for Container Template. Document Windows defaults in the help. --- .../jenkins/plugins/kubernetes/ContainerTemplate.java | 10 ++++++++-- .../plugins/kubernetes/ContainerTemplate/config.jelly | 4 ++-- .../kubernetes/ContainerTemplate/help-args.html | 5 +++-- .../kubernetes/ContainerTemplate/help-command.html | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate.java index 23e43e64a1..c89ecea47c 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate.java @@ -26,6 +26,8 @@ import jenkins.model.Jenkins; import org.kohsuke.stapler.QueryParameter; +import javax.annotation.CheckForNull; + public class ContainerTemplate extends AbstractDescribableImpl implements Serializable { @@ -133,8 +135,9 @@ public void setCommand(String command) { this.command = command; } + @CheckForNull public String getCommand() { - return command; + return this.command == null ? DescriptorImpl.defaultCommand : this.command; } @DataBoundSetter @@ -142,8 +145,9 @@ public void setArgs(String args) { this.args = args; } + @CheckForNull public String getArgs() { - return args; + return this.args == null ? DescriptorImpl.defaultArgs : this.args; } @DataBoundSetter @@ -350,6 +354,8 @@ public FormValidation doCheckImage(@QueryParameter String value) { public String getWorkingDir() { return DEFAULT_WORKING_DIR; } + public final static String defaultCommand = "sleep"; + public final static String defaultArgs = "9999999"; } @Override diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/config.jelly b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/config.jelly index 4ac6cc6590..8ce44aa9e2 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/config.jelly +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/config.jelly @@ -23,11 +23,11 @@ - + - + diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-args.html b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-args.html index 560a8b0672..b199cb6960 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-args.html +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-args.html @@ -1,2 +1,3 @@ -Arguments to pass to the command. -${computer.jnlpmac} and ${computer.name} are replaced with the agent secret and name respectively. +

Arguments to pass to the command.

+

${computer.jnlpmac} and ${computer.name} are replaced with the agent secret and name respectively.

+

For Windows containers the args ["Start-Sleep", "999999"] are reasonable choices to go with powershell.

diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-command.html b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-command.html index 095e37d80a..915eeb9b66 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-command.html +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-command.html @@ -1 +1,2 @@ -Override the image entrypoint with a different one \ No newline at end of file +

Override the image entrypoint with a different one.

+

For Windows containers 'powershell' is a good default.