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 SummaryFieldsModifier and TypeFieldDescriptionprotected String[]protected EnvVarsFilterableBuilderRepresent the build step, either from legacy build process or from pipeline oneprotected boolean[]protected FilePathprotected booleanTrue to reverse the I/O direction.protected booleanTrue to reverse the I/O direction.protected booleanTrue to reverse the I/O direction.protected OutputStreamprotected InputStreamprotected OutputStream
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.intjoin()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.booleanquiet()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 pumpstderrfrom the child process separately fromstdout.Indicates that the caller will pumpstdoutfrom the child process viaProc.getStdout()(whereas by default you callstdout(OutputStream)and let Jenkins pump stdout into yourOutputStreamof 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
- 
reverseStdinprotected boolean reverseStdinTrue to reverse the I/O direction. For example, ifreverseStdout==true, then we exposeInputStreamfromProcand expect the client to read from it, whereas normally we takeOutputStreamviastdout(OutputStream)and feed stdout into that output.- Since:
- 1.399
 
- 
reverseStdoutprotected boolean reverseStdoutTrue to reverse the I/O direction. For example, ifreverseStdout==true, then we exposeInputStreamfromProcand expect the client to read from it, whereas normally we takeOutputStreamviastdout(OutputStream)and feed stdout into that output.- Since:
- 1.399
 
- 
reverseStderrprotected boolean reverseStderrTrue to reverse the I/O direction. For example, ifreverseStdout==true, then we exposeInputStreamfromProcand expect the client to read from it, whereas normally we takeOutputStreamviastdout(OutputStream)and feed stdout into that output.- Since:
- 1.399
 
 
- 
- 
Constructor Details- 
ProcStarterpublic ProcStarter()
 
- 
- 
Method Details- 
cmdAsSingleStringPasses 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
- 
masksHide parts of the command line from being printed to the log.- Parameters:
- masks- true for each position in- cmds(String[])which should be masked, false to print
- Returns:
- this
- See Also:
 
- 
masks@CheckForNull public boolean[] masks()
- 
quietAllowsLauncher.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
 
- 
quietpublic boolean quiet()- Since:
- 1.576
 
- 
pwdSets the current directory.- Parameters:
- workDir- Work directory to be used. If- null, the default/current directory will be used by the process starter
- Returns:
- this
 
- 
pwd
- 
pwd
- 
pwd
- 
stdoutSets STDOUT destination.- Parameters:
- out- Output stream. Use- nullto send STDOUT to- /dev/null.
- Returns:
- this
 
- 
stdoutSends the stdout to the givenTaskListener.- Parameters:
- out- Task listener (must be safely remotable)
- Returns:
- this
 
- 
stdoutGets current STDOUT destination.- Returns:
- STDOUT output stream. nullif STDOUT is suppressed or undefined.
 
- 
stderrControls where the stderr of the process goes. By default, it's bundled into stdout.
- 
stderrGets current STDERR destination.- Returns:
- STDERR output stream. nullif suppressed or undefined.
 
- 
stdinControls where the stdin of the process comes from. By default,/dev/null.- Returns:
- this
 
- 
stdinGets current STDIN destination.- Returns:
- STDIN output stream. nullif suppressed or undefined.
 
- 
envsSets 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". See- envs(Map)for the semantics.
- Returns:
- this
 
- 
envsGets 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.
 
- 
readStdoutIndicates that the caller will pumpstdoutfrom the child process viaProc.getStdout()(whereas by default you callstdout(OutputStream)and let Jenkins pump stdout into yourOutputStreamof choosing.When this method is called, Proc.getStdout()will read the combined output ofstdout/stderrfrom the child process, unlessreadStderr()is called separately, which lets the caller read those two streams separately.- Returns:
- this
- Since:
- 1.399
 
- 
readStderrIn addition to the effect ofreadStdout(), indicate that the caller will pumpstderrfrom the child process separately fromstdout. The stderr will be readable fromProc.getStderr()whileProc.getStdout()reads from stdout.- Returns:
- this
- Since:
- 1.399
 
- 
writeStdinIndicates that the caller will directly write to the child processstdin()viaProc.getStdin(). (Whereas by default you callstdin(InputStream)and let Jenkins pump yourInputStreamof 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
 
- 
startStarts the new process as configured.- Throws:
- IOException
 
- 
joinStarts 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
 
- 
copyCopies aLauncher.ProcStarter.
 
-