public LocalProc(String[] cmd, Map<String,String> env,InputStream in, OutputStream out) throws IOException { this(cmd,Util.mapToEnv(env),in,out); }
public LocalProc(String cmd, Map<String,String> env, OutputStream out, File workDir) throws IOException { this(cmd,Util.mapToEnv(env),out,workDir); }
/** * Sets the environment variable overrides. * * <p> * 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. * * @param overrides Environment variables to be overridden * @return {@code this} */ public ProcStarter envs(@Nonnull Map<String, String> overrides) { this.envs = Util.mapToEnv(overrides); return this; }
/** * @deprecated as of 1.311 * Use {@link #launch()} and its associated builder pattern */ @Deprecated public final Proc launch(String cmd, Map<String,String> env, OutputStream out, FilePath workDir) throws IOException { return launch(cmd,Util.mapToEnv(env),out,workDir); }
/** * @deprecated as of 1.311 * Use {@link #launch()} and its associated builder pattern */ @Deprecated public final Proc launch(String[] cmd, Map<String, String> env, OutputStream out, FilePath workDir) throws IOException { return launch(cmd, Util.mapToEnv(env), out, workDir); }
/** * @deprecated as of 1.311 * Use {@link #launch()} and its associated builder pattern */ @Deprecated public final Proc launch(String[] cmd, Map<String, String> env, InputStream in, OutputStream out) throws IOException { return launch(cmd, Util.mapToEnv(env), in, out); }
/** * Launch a command with optional censoring of arguments from the listener (Note: <strong>The censored portions will * remain visible through /proc, pargs, process explorer, etc. i.e. people logged in on the same machine</strong> * This version of the launch command just ensures that it is not visible from a build log which is exposed via the * web) * * @param cmd The command and all it's arguments. * @param mask Which of the command and arguments should be masked from the listener * @param env Environment variable overrides. * @param out stdout and stderr of the process will be sent to this stream. the stream won't be closed. * @param workDir null if the working directory could be anything. * @return The process of the command. * @throws IOException When there are IO problems. * * @deprecated as of 1.311 * Use {@link #launch()} and its associated builder pattern */ @Deprecated public final Proc launch(String[] cmd, boolean[] mask, Map<String, String> env, OutputStream out, FilePath workDir) throws IOException { return launch(cmd, mask, Util.mapToEnv(env), out, workDir); }
/** * Launch a command with optional censoring of arguments from the listener (Note: <strong>The censored portions will * remain visible through /proc, pargs, process explorer, etc. i.e. people logged in on the same machine</strong> * This version of the launch command just ensures that it is not visible from a build log which is exposed via the * web) * * @param cmd The command and all it's arguments. * @param mask Which of the command and arguments should be masked from the listener * @param env Environment variable overrides. * @param in null if there's no input. * @param out stdout and stderr of the process will be sent to this stream. the stream won't be closed. * @return The process of the command. * @throws IOException When there are IO problems. * * @deprecated as of 1.311 * Use {@link #launch()} and its associated builder pattern */ @Deprecated public final Proc launch(String[] cmd, boolean[] mask, Map<String, String> env, InputStream in, OutputStream out) throws IOException { return launch(cmd, mask, Util.mapToEnv(env), in, out); }
public OutputStream call() throws IOException { Process p = Runtime.getRuntime().exec(cmd, Util.mapToEnv(inherit(envOverrides)), workDir == null ? null : new File(workDir)); List<String> cmdLines = Arrays.asList(cmd); new StreamCopyThread("stdin copier for remote agent on "+cmdLines, p.getInputStream(), out.getOut()).start(); new StreamCopyThread("stderr copier for remote agent on "+cmdLines, p.getErrorStream(), err).start(); // TODO: don't we need to join? return new RemoteOutputStream(p.getOutputStream()); }
@Override public Proc launch(ProcStarter starter) throws IOException { EnvVars e = new EnvVars(env); if (starter.envs!=null) { for (String env : starter.envs) { e.addLine(env); } } starter.envs = Util.mapToEnv(e); return outer.launch(starter); }
@Override public Proc launch(ProcStarter ps) throws IOException { if (!ps.quiet) { maskedPrintCommandLine(ps.commands, ps.masks, ps.pwd); } EnvVars jobEnv = inherit(ps.envs); // replace variables in command line String[] jobCmd = new String[ps.commands.size()]; for ( int idx = 0 ; idx < jobCmd.length; idx++ ) jobCmd[idx] = jobEnv.expand(ps.commands.get(idx)); return new LocalProc(jobCmd, Util.mapToEnv(jobEnv), ps.reverseStdin ?LocalProc.SELFPUMP_INPUT:ps.stdin, ps.reverseStdout?LocalProc.SELFPUMP_OUTPUT:ps.stdout, ps.reverseStderr?LocalProc.SELFPUMP_OUTPUT:ps.stderr, toFile(ps.pwd)); }
/** * @deprecated as of 1.311 * Use {@link #launch()} and its associated builder pattern */ @Deprecated public final Proc launch(String cmd, Map<String,String> env, OutputStream out, FilePath workDir) throws IOException { return launch(cmd,Util.mapToEnv(env),out,workDir); }
/** * @deprecated as of 1.311 * Use {@link #launch()} and its associated builder pattern */ @Deprecated public final Proc launch(String[] cmd, Map<String, String> env, InputStream in, OutputStream out) throws IOException { return launch(cmd, Util.mapToEnv(env), in, out); }
/** * @deprecated as of 1.311 * Use {@link #launch()} and its associated builder pattern */ public final Proc launch(String cmd, Map<String,String> env, OutputStream out, FilePath workDir) throws IOException { return launch(cmd,Util.mapToEnv(env),out,workDir); }
/** * Sets the environment variable overrides. * * <p> * 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. */ public ProcStarter envs(Map<String, String> overrides) { return envs(Util.mapToEnv(overrides)); }
/** * Sets the environment variable overrides. * * <p> 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. */ public ProcStarter envs(Map<String, String> overrides) { return envs(Util.mapToEnv(overrides)); }
/** * @deprecated as of 1.311 * Use {@link #launch()} and its associated builder pattern */ public final Proc launch(String[] cmd, Map<String, String> env, InputStream in, OutputStream out) throws IOException { return launch(cmd, Util.mapToEnv(env), in, out); }
/** * @deprecated as of 1.311 Use {@link #launch()} and its associated builder * pattern */ public final Proc launch(String[] cmd, Map<String, String> env, OutputStream out, FilePath workDir) throws IOException { return launch(cmd, Util.mapToEnv(env), out, workDir); }
/** * @deprecated as of 1.311 Use {@link #launch()} and its associated builder * pattern */ public final Proc launch(String cmd, Map<String, String> env, OutputStream out, FilePath workDir) throws IOException { return launch(cmd, Util.mapToEnv(env), out, workDir); }
public OutputStream call() throws IOException { Process p = Runtime.getRuntime().exec(cmd, Util.mapToEnv(inherit(envOverrides)), workDir == null ? null : new File(workDir)); List<String> cmdLines = Arrays.asList(cmd); new StreamCopyThread("stdin copier for remote agent on "+cmdLines, p.getInputStream(), out.getOut()).start(); new StreamCopyThread("stderr copier for remote agent on "+cmdLines, p.getErrorStream(), err).start(); // TODO: don't we need to join? return new RemoteOutputStream(p.getOutputStream()); }