hudson
Class Launcher.ProcStarter

java.lang.Object
  extended by hudson.Launcher.ProcStarter
Enclosing class:
Launcher

public final class Launcher.ProcStarter
extends Object

Builder pattern for configuring a process to launch.

Since:
1.311

Field Summary
protected  List<String> commands
           
protected  String[] envs
           
protected  boolean[] masks
           
protected  FilePath pwd
           
protected  boolean reverseStderr
          True to reverse the I/O direction.
protected  boolean reverseStdin
          True to reverse the I/O direction.
protected  boolean reverseStdout
          True to reverse the I/O direction.
protected  OutputStream stderr
           
protected  InputStream stdin
           
protected  OutputStream stdout
           
 
Constructor Summary
Launcher.ProcStarter()
           
 
Method Summary
 Launcher.ProcStarter cmdAsSingleString(String s)
          Passes a white-space separated single-string command (like "cat abc def") and parse them as a command argument.
 List<String> cmds()
           
 Launcher.ProcStarter cmds(ArgumentListBuilder args)
           
 Launcher.ProcStarter cmds(File program, String... args)
           
 Launcher.ProcStarter cmds(List<String> args)
           
 Launcher.ProcStarter cmds(String... args)
           
 Launcher.ProcStarter copy()
          Copies a Launcher.ProcStarter.
 String[] envs()
           
 Launcher.ProcStarter envs(Map<String,String> overrides)
          Sets the environment variable overrides.
 Launcher.ProcStarter envs(String... overrides)
           
 int join()
          Starts the process and waits for its completion.
 boolean[] masks()
           
 Launcher.ProcStarter masks(boolean... masks)
          Hide parts of the command line from being printed to the log.
 FilePath pwd()
           
 Launcher.ProcStarter pwd(File workDir)
           
 Launcher.ProcStarter pwd(FilePath workDir)
           
 Launcher.ProcStarter pwd(String workDir)
           
 Launcher.ProcStarter readStderr()
          In addition to the effect of readStdout(), indicate that the caller will pump stderr from the child process separately from stdout.
 Launcher.ProcStarter readStdout()
          Indicates that the caller will pump stdout from the child process via Proc.getStdout() (whereas by default you call stdout(OutputStream) and let Jenkins pump stdout into your OutputStream of choosing.
 Proc start()
          Starts the new process as configured.
 OutputStream stderr()
           
 Launcher.ProcStarter stderr(OutputStream err)
          Controls where the stderr of the process goes.
 InputStream stdin()
           
 Launcher.ProcStarter stdin(InputStream in)
          Controls where the stdin of the process comes from.
 OutputStream stdout()
           
 Launcher.ProcStarter stdout(OutputStream out)
           
 Launcher.ProcStarter stdout(TaskListener out)
          Sends the stdout to the given TaskListener.
 Launcher.ProcStarter writeStdin()
          Indicates that the caller will directly write to the child process stdin() via Proc.getStdin().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commands

protected List<String> commands

masks

protected boolean[] masks

pwd

protected FilePath pwd

stdout

protected OutputStream stdout

stderr

protected OutputStream stderr

stdin

protected InputStream stdin

envs

protected String[] envs

reverseStdin

protected boolean reverseStdin
True to reverse the I/O direction. For example, if reverseStdout==true, then we expose InputStream from Proc and expect the client to read from it, whereas normally we take OutputStream via stdout(OutputStream) and feed stdout into that output.

Since:
1.399

reverseStdout

protected boolean reverseStdout
True to reverse the I/O direction. For example, if reverseStdout==true, then we expose InputStream from Proc and expect the client to read from it, whereas normally we take OutputStream via stdout(OutputStream) and feed stdout into that output.

Since:
1.399

reverseStderr

protected boolean reverseStderr
True to reverse the I/O direction. For example, if reverseStdout==true, then we expose InputStream from Proc and expect the client to read from it, whereas normally we take OutputStream via stdout(OutputStream) and feed stdout into that output.

Since:
1.399
Constructor Detail

Launcher.ProcStarter

public Launcher.ProcStarter()
Method Detail

cmdAsSingleString

public Launcher.ProcStarter cmdAsSingleString(String s)
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

public Launcher.ProcStarter cmds(String... args)

cmds

public Launcher.ProcStarter cmds(File program,
                                 String... args)

cmds

public Launcher.ProcStarter cmds(List<String> args)

cmds

public Launcher.ProcStarter cmds(ArgumentListBuilder args)

cmds

public List<String> cmds()

masks

public Launcher.ProcStarter masks(boolean... masks)
Hide 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:
ArgumentListBuilder.add(String, boolean), Launcher.maskedPrintCommandLine(List, boolean[], FilePath)

masks

public boolean[] masks()

pwd

public Launcher.ProcStarter pwd(FilePath workDir)

pwd

public Launcher.ProcStarter pwd(File workDir)

pwd

public Launcher.ProcStarter pwd(String workDir)

pwd

public FilePath pwd()

stdout

public Launcher.ProcStarter stdout(OutputStream out)

stdout

public Launcher.ProcStarter stdout(TaskListener out)
Sends the stdout to the given TaskListener.


stdout

public OutputStream stdout()

stderr

public Launcher.ProcStarter stderr(OutputStream err)
Controls where the stderr of the process goes. By default, it's bundled into stdout.


stderr

public OutputStream stderr()

stdin

public Launcher.ProcStarter stdin(InputStream in)
Controls where the stdin of the process comes from. By default, /dev/null.


stdin

public InputStream stdin()

envs

public Launcher.ProcStarter envs(Map<String,String> overrides)
Sets the environment variable overrides.

In adition to what the current process is inherited (if this is going to be launched from a slave agent, that becomes the "current" process), these variables will be also set.


envs

public Launcher.ProcStarter envs(String... overrides)
Parameters:
overrides - List of "VAR=VALUE". See envs(Map) for the semantics.

envs

public String[] envs()

readStdout

public Launcher.ProcStarter readStdout()
Indicates that the caller will pump stdout from the child process via Proc.getStdout() (whereas by default you call stdout(OutputStream) and let Jenkins pump stdout into your OutputStream of choosing.

When this method is called, Proc.getStdout() will read the combined output of stdout/stderr from the child process, unless readStderr() is called separately, which lets the caller read those two streams separately.

Since:
1.399

readStderr

public Launcher.ProcStarter readStderr()
In addition to the effect of readStdout(), indicate that the caller will pump stderr from the child process separately from stdout. The stderr will be readable from Proc.getStderr() while Proc.getStdout() reads from stdout.

Since:
1.399

writeStdin

public Launcher.ProcStarter writeStdin()
Indicates that the caller will directly write to the child process stdin() via Proc.getStdin(). (Whereas by default you call stdin(InputStream) and let Jenkins pump your InputStream of choosing to stdin.)

Since:
1.399

start

public Proc start()
           throws IOException
Starts the new process as configured.

Throws:
IOException

join

public int join()
         throws IOException,
                InterruptedException
Starts the process and waits for its completion.

Throws:
IOException
InterruptedException

copy

public Launcher.ProcStarter copy()
Copies a Launcher.ProcStarter.



Copyright © 2004-2013. All Rights Reserved.