Skip to content

Commit

Permalink
[JENKINS-57841] Change defaults for command and args for Container Te…
Browse files Browse the repository at this point in the history
…mplate. Document Windows defaults in the help.
  • Loading branch information
kerogers-cloudbees committed Dec 9, 2020
1 parent a8eba67 commit ce73ef5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Expand Up @@ -26,6 +26,8 @@
import jenkins.model.Jenkins;
import org.kohsuke.stapler.QueryParameter;

import javax.annotation.CheckForNull;


public class ContainerTemplate extends AbstractDescribableImpl<ContainerTemplate> implements Serializable {

Expand Down Expand Up @@ -133,17 +135,19 @@ public void setCommand(String command) {
this.command = command;
}

@CheckForNull
public String getCommand() {
return command;
return this.command == null ? DescriptorImpl.defaultCommand : this.command;
}

@DataBoundSetter
public void setArgs(String args) {
this.args = args;
}

@CheckForNull
public String getArgs() {
return args;
return this.args == null ? DescriptorImpl.defaultArgs : this.args;
}

@DataBoundSetter
Expand Down Expand Up @@ -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
Expand Down
Expand Up @@ -23,11 +23,11 @@
</f:entry>

<f:entry field="command" title="${%Command to run}">
<f:textbox default="/bin/sh -c"/>
<f:textbox default="${descriptor.defaultCommand}"/>
</f:entry>

<f:entry field="args" title="${%Arguments to pass to the command}">
<f:textbox default="cat"/>
<f:textbox default="${descriptor.defaultArgs}"/>
</f:entry>

<f:entry field="ttyEnabled" title="${%Allocate pseudo-TTY}">
Expand Down
@@ -1,2 +1,3 @@
Arguments to pass to the command.
${computer.jnlpmac} and ${computer.name} are replaced with the agent secret and name respectively.
<p>Arguments to pass to the command.</p>
<p>${computer.jnlpmac} and ${computer.name} are replaced with the agent secret and name respectively.</p>
<p>For Windows containers the args ["Start-Sleep", "999999"] are reasonable choices to go with powershell.</p>
@@ -1 +1,2 @@
Override the image entrypoint with a different one
<p>Override the image entrypoint with a different one.</p>
<p>For Windows containers 'powershell' is a good default.</p>

0 comments on commit ce73ef5

Please sign in to comment.