Package hudson
Class Launcher.ProcStarter
java.lang.Object
hudson.Launcher.ProcStarter
- Enclosing class:
- Launcher
Builder pattern for configuring a process to launch.
- Since:
- 1.311
-
Field Summary
Modifier and TypeFieldDescriptionprotected String[]
protected EnvVarsFilterableBuilder
Represent the build step, either from legacy build process or from pipeline oneprotected boolean[]
protected FilePath
protected boolean
True to reverse the I/O direction.protected boolean
True to reverse the I/O direction.protected boolean
True to reverse the I/O direction.protected OutputStream
protected InputStream
protected OutputStream
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuildStep
(EnvVarsFilterableBuilder envVarsFilterableBuilder) Specify the build step that want to run the command to enable the environment filtersPasses a white-space separated single-string command (like "cat abc def") and parse them as a command argument.cmds()
cmds
(ArgumentListBuilder args) copy()
Copies aLauncher.ProcStarter
.String[]
envs()
Gets a list of environment variables to be set.Sets the environment variable overrides.int
join()
Starts the process and waits for its completion.boolean[]
masks()
masks
(boolean... masks) Hide parts of the command line from being printed to the log.pwd()
Sets the current directory.boolean
quiet()
quiet
(boolean quiet) AllowsLauncher.maskedPrintCommandLine(List, boolean[], FilePath)
to be suppressed fromLauncher.LocalLauncher.launch(hudson.Launcher.ProcStarter)
.In addition to the effect ofreadStdout()
, indicate that the caller will pumpstderr
from the child process separately fromstdout
.Indicates that the caller will pumpstdout
from the child process viaProc.getStdout()
(whereas by default you callstdout(OutputStream)
and let Jenkins pump stdout into yourOutputStream
of choosing.start()
Starts the new process as configured.stderr()
Gets current STDERR destination.stderr
(OutputStream err) Controls where the stderr of the process goes.stdin()
Gets current STDIN destination.stdin
(InputStream in) Controls where the stdin of the process comes from.stdout()
Gets current STDOUT destination.stdout
(TaskListener out) Sends the stdout to the givenTaskListener
.stdout
(OutputStream out) Sets STDOUT destination.Indicates that the caller will directly write to the child processstdin()
viaProc.getStdin()
.
-
Field Details
-
commands
-
masks
@CheckForNull protected boolean[] masks -
pwd
-
stdout
-
stderr
-
stdin
-
envs
-
envVarsFilterableBuilder
@CheckForNull @Restricted(org.kohsuke.accmod.restrictions.Beta.class) protected EnvVarsFilterableBuilder envVarsFilterableBuilderRepresent the build step, either from legacy build process or from pipeline one -
reverseStdin
protected boolean reverseStdinTrue to reverse the I/O direction. For example, ifreverseStdout
==true, then we exposeInputStream
fromProc
and expect the client to read from it, whereas normally we takeOutputStream
viastdout(OutputStream)
and feed stdout into that output.- Since:
- 1.399
-
reverseStdout
protected boolean reverseStdoutTrue to reverse the I/O direction. For example, ifreverseStdout
==true, then we exposeInputStream
fromProc
and expect the client to read from it, whereas normally we takeOutputStream
viastdout(OutputStream)
and feed stdout into that output.- Since:
- 1.399
-
reverseStderr
protected boolean reverseStderrTrue to reverse the I/O direction. For example, ifreverseStdout
==true, then we exposeInputStream
fromProc
and expect the client to read from it, whereas normally we takeOutputStream
viastdout(OutputStream)
and feed stdout into that output.- Since:
- 1.399
-
-
Constructor Details
-
ProcStarter
public ProcStarter()
-
-
Method Details
-
cmdAsSingleString
Passes a white-space separated single-string command (like "cat abc def") and parse them as a command argument. This method also handles quotes. -
cmds
-
cmds
-
cmds
-
cmds
-
cmds
-
masks
Hide parts of the command line from being printed to the log.- Parameters:
masks
- true for each position incmds(String[])
which should be masked, false to print- Returns:
- this
- See Also:
-
masks
@CheckForNull public boolean[] masks() -
quiet
AllowsLauncher.maskedPrintCommandLine(List, boolean[], FilePath)
to be suppressed fromLauncher.LocalLauncher.launch(hudson.Launcher.ProcStarter)
. Useful when the actual command being printed is noisy and unreadable and the caller would rather print diagnostic information in a customized way.- Parameters:
quiet
- to suppress printing the command line when starting the process; false to keep default behavior of printing- Returns:
this
- Since:
- 1.576
-
quiet
public boolean quiet()- Since:
- 1.576
-
pwd
Sets the current directory.- Parameters:
workDir
- Work directory to be used. Ifnull
, the default/current directory will be used by the process starter- Returns:
this
-
pwd
-
pwd
-
pwd
-
stdout
Sets STDOUT destination.- Parameters:
out
- Output stream. Usenull
to send STDOUT to/dev/null
.- Returns:
this
-
stdout
Sends the stdout to the givenTaskListener
.- Parameters:
out
- Task listener (must be safely remotable)- Returns:
this
-
stdout
Gets current STDOUT destination.- Returns:
- STDOUT output stream.
null
if STDOUT is suppressed or undefined.
-
stderr
Controls where the stderr of the process goes. By default, it's bundled into stdout. -
stderr
Gets current STDERR destination.- Returns:
- STDERR output stream.
null
if suppressed or undefined.
-
stdin
Controls where the stdin of the process comes from. By default,/dev/null
.- Returns:
this
-
stdin
Gets current STDIN destination.- Returns:
- STDIN output stream.
null
if suppressed or undefined.
-
envs
Sets the environment variable overrides.In addition to what the current process is inherited (if this is going to be launched from a agent agent, that becomes the "current" process), these variables will be also set.
- Parameters:
overrides
- Environment variables to be overridden- Returns:
this
-
envs
- Parameters:
overrides
- List of "VAR=VALUE". Seeenvs(Map)
for the semantics.- Returns:
this
-
envs
Gets a list of environment variables to be set. Returns an empty array if envs field has not been initialized.- Returns:
- If initialized, returns a copy of internal envs array. Otherwise - a new empty array.
-
readStdout
Indicates that the caller will pumpstdout
from the child process viaProc.getStdout()
(whereas by default you callstdout(OutputStream)
and let Jenkins pump stdout into yourOutputStream
of choosing.When this method is called,
Proc.getStdout()
will read the combined output ofstdout/stderr
from the child process, unlessreadStderr()
is called separately, which lets the caller read those two streams separately.- Returns:
this
- Since:
- 1.399
-
readStderr
In addition to the effect ofreadStdout()
, indicate that the caller will pumpstderr
from the child process separately fromstdout
. The stderr will be readable fromProc.getStderr()
whileProc.getStdout()
reads from stdout.- Returns:
this
- Since:
- 1.399
-
writeStdin
Indicates that the caller will directly write to the child processstdin()
viaProc.getStdin()
. (Whereas by default you callstdin(InputStream)
and let Jenkins pump yourInputStream
of choosing to stdin.)- Returns:
this
- Since:
- 1.399
-
buildStep
@Restricted(org.kohsuke.accmod.restrictions.Beta.class) public Launcher.ProcStarter buildStep(EnvVarsFilterableBuilder envVarsFilterableBuilder) Specify the build step that want to run the command to enable the environment filters- Returns:
this
- Since:
- 2.246
-
buildStep
@Restricted(org.kohsuke.accmod.restrictions.Beta.class) @CheckForNull public EnvVarsFilterableBuilder buildStep()- Returns:
- if set, returns the build step that wants to run the command
- Since:
- 2.246
-
start
Starts the new process as configured.- Throws:
IOException
-
join
Starts the process and waits for its completion.- Returns:
- Return code of the invoked process
- Throws:
IOException
- Operation error (e.g. remote call failure)InterruptedException
- The process has been interrupted
-
copy
Copies aLauncher.ProcStarter
.
-