/** * Primarily invoked from {@link ProcStarter#start()} to start a process with a specific launcher. */ public abstract Proc launch(@Nonnull ProcStarter starter) throws IOException;
/** * Copies a {@link ProcStarter}. */ @Nonnull public ProcStarter copy() { ProcStarter rhs = new ProcStarter().cmds(commands).pwd(pwd).masks(masks).stdin(stdin).stdout(stdout).stderr(stderr).envs(envs).quiet(quiet); rhs.stdoutListener = stdoutListener; rhs.reverseStdin = this.reverseStdin; rhs.reverseStderr = this.reverseStderr; rhs.reverseStdout = this.reverseStdout; return rhs; } }
public RemoteProcess call() throws IOException { final Channel channel = getOpenChannelOrFail(); Launcher.ProcStarter ps = new LocalLauncher(listener).launch(); ps.cmds(cmd).masks(masks).envs(env).stdin(in).stderr(err).quiet(quiet); if (stdoutListener != null) { ps.stdout(stdoutListener.getLogger());
public Integer call() throws IOException { Launcher.ProcStarter ps = new LocalLauncher(listener).launch(); ps.cmds(cmd).masks(masks).envs(env).stdin(in).stdout(out).stderr(err); if (workDir != null) { ps.pwd(workDir); } Proc p = ps.start(); try { return p.join(); } catch (InterruptedException e) { return -1; } finally { try { // Fix: http://issues.hudson-ci.org/browse/HUDSON-7809 // This call should not return immediately after the // process is done. The pipe associated with the channel // may be still transmitting data. // Get the channel associated with this thread and flush // its IO pipe Channel.current().flushPipe(); } catch (InterruptedException ex) { Logger.getLogger(Launcher.class.getName()).log(Level.INFO, null, ex); } } } private static final long serialVersionUID = 1L;
public Integer call() throws IOException { Launcher.ProcStarter ps = new LocalLauncher(listener).launch(); ps.cmds(cmd).masks(masks).envs(env).stdin(in).stdout(out).stderr(err); if(workDir!=null) ps.pwd(workDir); Proc p = ps.start(); try { return p.join(); } catch (InterruptedException e) { return -1; } finally{ try { // Fix: http://issues.hudson-ci.org/browse/HUDSON-7809 // This call should not return immediately after the // process is done. The pipe associated with the channel // may be still transmitting data. // Get the channel associated with this thread and flush // its IO pipe Channel.current().flushPipe(); } catch (InterruptedException ex) { Logger.getLogger(Launcher.class.getName()).log(Level.INFO, null, ex); } } }
public Integer call() throws IOException { Launcher.ProcStarter ps = new LocalLauncher(listener).launch(); ps.cmds(cmd).masks(masks).envs(env).stdin(in).stdout(out).stderr(err); if(workDir!=null) ps.pwd(workDir); Proc p = ps.start(); try { return p.join(); } catch (InterruptedException e) { return -1; } finally{ try { // Fix: http://issues.hudson-ci.org/browse/HUDSON-7809 // This call should not return immediately after the // process is done. The pipe associated with the channel // may be still transmitting data. // Get the channel associated with this thread and flush // its IO pipe Channel.current().flushPipe(); } catch (InterruptedException ex) { Logger.getLogger(Launcher.class.getName()).log(Level.INFO, null, ex); } } }
@Override public Proc execInContainer(TaskListener listener, String containerId, Launcher.ProcStarter starter) throws IOException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder() .add("exec", containerId); if (starter.pwd() != null) { args.add("/trampoline", "cdexec", starter.pwd().getRemote()); } args.add("env").add(starter.envs()); List<String> originalCmds = starter.cmds(); boolean[] originalMask = starter.masks(); for (int i = 0; i < originalCmds.size(); i++) { boolean masked = originalMask == null ? false : i < originalMask.length ? originalMask[i] : false; args.add(originalCmds.get(i), masked); } Launcher launcher = new Launcher.LocalLauncher(listener); Launcher.ProcStarter procStarter = launchDockerCLI(launcher, args); if (starter.stdout() != null) { procStarter.stdout(starter.stdout()); } return procStarter.start(); }
public void executeIn(String container, String userId, Launcher.ProcStarter starter, EnvVars environment) throws IOException, InterruptedException { List<String> prefix = dockerCommandArgs(); prefix.add("exec"); prefix.add("--tty"); prefix.add("--user"); prefix.add(userId); prefix.add(container); prefix.add("env"); // Build a list of environment, hidding node's one for (Map.Entry<String, String> e : environment.entrySet()) { prefix.add(e.getKey()+"="+e.getValue()); } starter.cmds().addAll(0, prefix); if (starter.masks() != null) { boolean[] masks = new boolean[starter.masks().length + prefix.size()]; System.arraycopy(starter.masks(), 0, masks, prefix.size(), starter.masks().length); starter.masks(masks); } starter.envs(getEnvVars()); }
@Override public Proc execInContainer(TaskListener listener, String containerId, Launcher.ProcStarter starter) throws IOException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder() .add("exec", containerId); if (starter.pwd() != null) { args.add("/trampoline", "cdexec", starter.pwd().getRemote()); } args.add("env").add(starter.envs()); List<String> originalCmds = starter.cmds(); boolean[] originalMask = starter.masks(); for (int i = 0; i < originalCmds.size(); i++) { boolean masked = originalMask == null ? false : i < originalMask.length ? originalMask[i] : false; args.add(originalCmds.get(i), masked); } Launcher launcher = new Launcher.LocalLauncher(listener); Launcher.ProcStarter procStarter = launchDockerCLI(launcher, args); if (starter.stdout() != null) { procStarter.stdout(starter.stdout()); } return procStarter.start(); }
public Proc launch(String[] cmd, boolean[] mask, String[] env, InputStream in, OutputStream out, FilePath workDir) throws IOException { return launch(launch().cmds(cmd).masks(mask).envs(env).stdin(in).stdout(out).pwd(workDir)); }
/** * Primarily invoked from {@link ProcStarter#start()} to start a process with a specific launcher. */ public abstract Proc launch(ProcStarter starter) throws IOException;
/** * Primarily invoked from {@link ProcStarter#start()} to start a process with a specific launcher. */ public abstract Proc launch(ProcStarter starter) throws IOException;
/** * Copies a {@link ProcStarter}. */ public ProcStarter copy() { return new ProcStarter().cmds(commands).pwd(pwd).masks(masks).stdin(stdin).stdout(stdout).stderr(stderr).envs(envs); } }
/** * Primarily invoked from {@link ProcStarter#start()} to start a process with a specific launcher. */ public abstract Proc launch(ProcStarter starter) throws IOException;
/** * Copies a {@link ProcStarter}. */ public ProcStarter copy() { return new ProcStarter().cmds(commands).pwd(pwd).masks(masks).stdin(stdin).stdout(stdout).stderr(stderr).envs(envs); } }
/** * Primarily invoked from {@link ProcStarter#start()} to start a process * with a specific launcher. */ public abstract Proc launch(ProcStarter starter) throws IOException;
/** * Copies a {@link ProcStarter}. */ public ProcStarter copy() { return new ProcStarter().cmds(commands).pwd(pwd).masks(masks).stdin(stdin).stdout(stdout).stderr(stderr).envs(envs); } }
/** * Copies a {@link ProcStarter}. */ public ProcStarter copy() { return new ProcStarter().cmds(commands).pwd(pwd).masks(masks).stdin(stdin).stdout(stdout).stderr(stderr).envs(envs); } }
/** * Primarily invoked from {@link ProcStarter#start()} to start a process with a specific launcher. */ public abstract Proc launch(@Nonnull ProcStarter starter) throws IOException;
/** * Copies a {@link ProcStarter}. */ @Nonnull public ProcStarter copy() { ProcStarter rhs = new ProcStarter().cmds(commands).pwd(pwd).masks(masks).stdin(stdin).stdout(stdout).stderr(stderr).envs(envs).quiet(quiet); rhs.reverseStdin = this.reverseStdin; rhs.reverseStderr = this.reverseStderr; rhs.reverseStdout = this.reverseStdout; return rhs; } }