public abstract class ShellStep extends Object implements Step
Modifier and Type | Field and Description |
---|---|
protected Path |
workingDirectory
If specified, working directory will be different from build cell root.
|
Modifier | Constructor and Description |
---|---|
protected |
ShellStep(AbsPath workingDirectory) |
protected |
ShellStep(Path workingDirectory) |
Modifier and Type | Method and Description |
---|---|
protected void |
addOptions(com.google.common.collect.ImmutableSet.Builder<ProcessExecutor.Option> options) |
StepExecutionResult |
execute(ExecutionContext context) |
String |
getDescription(ExecutionContext context) |
long |
getDuration() |
com.google.common.collect.ImmutableMap<String,String> |
getEnvironmentVariables(ExecutionContext context)
Returns the environment variables to include when running this
ShellStep . |
protected int |
getExitCodeFromResult(ExecutionContext context,
ProcessExecutor.Result result) |
com.google.common.collect.ImmutableList<String> |
getShellCommand(ExecutionContext context)
This method is idempotent.
|
protected com.google.common.collect.ImmutableList<String> |
getShellCommandArgsForDescription(ExecutionContext context) |
protected abstract com.google.common.collect.ImmutableList<String> |
getShellCommandInternal(ExecutionContext context)
Implementations of this method should not have any observable side-effects.
|
String |
getStderr() |
protected Optional<String> |
getStdin(ExecutionContext context) |
String |
getStdout() |
protected Optional<Long> |
getTimeout() |
protected Optional<java.util.function.Consumer<Process>> |
getTimeoutHandler(ExecutionContext context) |
protected boolean |
shouldPrintStderr(Verbosity verbosity) |
protected boolean |
shouldPrintStdout(Verbosity verbosity) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getShortName
protected final Path workingDirectory
protected ShellStep(Path workingDirectory)
protected ShellStep(AbsPath workingDirectory)
public StepExecutionResult execute(ExecutionContext context) throws InterruptedException, IOException
execute
in interface Step
InterruptedException
IOException
protected int getExitCodeFromResult(ExecutionContext context, ProcessExecutor.Result result)
result
.protected void addOptions(com.google.common.collect.ImmutableSet.Builder<ProcessExecutor.Option> options)
public long getDuration()
public final com.google.common.collect.ImmutableList<String> getShellCommand(ExecutionContext context)
protected com.google.common.collect.ImmutableList<String> getShellCommandArgsForDescription(ExecutionContext context)
protected Optional<String> getStdin(ExecutionContext context) throws InterruptedException, IOException
InterruptedException
IOException
protected abstract com.google.common.collect.ImmutableList<String> getShellCommandInternal(ExecutionContext context)
public final String getDescription(ExecutionContext context)
getDescription
in interface Step
public com.google.common.collect.ImmutableMap<String,String> getEnvironmentVariables(ExecutionContext context)
ShellStep
.
By default, this method returns an empty map.
context
- that may be useful when determining environment variables to include.protected boolean shouldPrintStdout(Verbosity verbosity)
verbosity
- is provided in case that affects what should be printed.ExecutionContext
. If false
, stdout will only be printed on
error and only if verbosity is set to standard information.public final String getStdout()
protected boolean shouldPrintStderr(Verbosity verbosity)
ExecutionContext
. If false
, stderr will only be printed on
error and only if verbosity is set to standard information.public final String getStderr()
protected Optional<java.util.function.Consumer<Process>> getTimeoutHandler(ExecutionContext context)
Function
to do something before the process is
killed.