public ProcStarter pwd(@Nonnull String workDir) { return pwd(new File(workDir)); }
return new LocalLauncher(out).launch().cmds(jenkinsExe, command).stdout(out).pwd(pwd).join(); } catch (IOException e) { if (e.getMessage().contains("CreateProcess") && e.getMessage().contains("=740")) {
@Override public void restart() throws IOException, InterruptedException { Jenkins jenkins = Jenkins.getInstanceOrNull(); try { if (jenkins != null) { jenkins.cleanUp(); } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); } File me = getHudsonWar(); File home = me.getParentFile(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamTaskListener task = new StreamTaskListener(baos); task.getLogger().println("Restarting a service"); String exe = System.getenv("WINSW_EXECUTABLE"); File executable; if (exe!=null) executable = new File(exe); else executable = new File(home, "hudson.exe"); if (!executable.exists()) executable = new File(home, "jenkins.exe"); // use restart! to run hudson/jenkins.exe restart in a separate process, so it doesn't kill itself int r = new LocalLauncher(task).launch().cmds(executable, "restart!") .stdout(task).pwd(home).join(); if(r!=0) throw new IOException(baos.toString()); }
/** * Primarily invoked from {@link ProcStarter#start()} to start a process * with a specific launcher. */ public abstract Proc launch(ProcStarter starter) throws IOException;
/** * Fills a {@link ProcStarter} with all the parameters configured by this builder. */ public ProcStarter launch(Launcher launcher) { return launcher.launch().cmds(toFullArguments()).pwd(pwd); }
private void createSideContainers(Launcher.ProcStarter starter, TaskListener listener) throws IOException, InterruptedException { for (SideContainerDefinition definition : spec.getSideContainers()) { final String name = definition.getName(); final ContainerDefinition sidecar = definition.getSpec(); final String image = sidecar.getImage(driver, starter.pwd(), listener); listener.getLogger().println("Starting " + name + " container"); Container container = driver.launchSideContainer(listener, image, context.getRemotingContainer(), sidecar.getHints()); context.getSideContainers().put(name, container); } }
/** * 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; } }
/** * Fills a {@link ProcStarter} with all the parameters configured by this * builder. */ public ProcStarter launch(Launcher launcher) { return launcher.launch().cmds(toFullArguments()).pwd(pwd); } private static final long serialVersionUID = 1L;
/** * Fills a {@link ProcStarter} with all the parameters configured by this builder. */ public ProcStarter launch(Launcher launcher) { return launcher.launch().cmds(toFullArguments()).pwd(pwd); }
int r = launcher.launch().cmds(args).envs(env).stdout(mca).pwd(build.getModuleRoot()).join(); if (0 != r) { return false;
envVars.put(e.getKey(),e.getValue()); r = join(launcher.launch().cmds(buildCommandLine(script)).envs(envVars).stdout(listener).pwd(ws).start());
ps.stdout(out); if(workDir!=null) ps.pwd(workDir); if (reverseStdin) ps.writeStdin(); if (reverseStdout) ps.readStdout();
Proc p = vmb.launch(new LocalLauncher(listener)).stdout(listener).pwd(workDir).start();
/** * @param env * Environment variable overrides. * @param in * null if there's no input. * @param workDir * null if the working directory could be anything. * @param out * stdout and stderr of the process will be sent to this stream. * the stream won't be closed. * * @deprecated as of 1.311 * Use {@link #launch()} and its associated builder pattern */ @Deprecated public Proc launch(String[] cmd, String[] env, InputStream in, OutputStream out, FilePath workDir) throws IOException { return launch(launch().cmds(cmd).envs(env).stdin(in).stdout(out).pwd(workDir)); }
@Override public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); // TODO support Unix scripts with interpreter line (see Shell.buildCommandLine) FilePath script = dir.createTextTempFile("hudson", getCommandFileExtension(), command); try { String cmd[] = getCommandCall(script); int r = node.createLauncher(log).launch().cmds(cmd).stdout(log).pwd(dir).join(); if (r != 0) { throw new IOException("Command returned status " + r); } } finally { script.delete(); } return dir.child(getToolHome()); }
private static int system(File pwd, TaskListener listener, String... args) throws IOException, InterruptedException { return new LocalLauncher(listener).launch().cmds(args).stdout(System.out).pwd(pwd).join(); }
public ProcStarter pwd(@Nonnull File workDir) { return pwd(new FilePath(workDir)); }
/** * 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; } }
/** * Fills a {@link ProcStarter} with all the parameters configured by this builder. */ public ProcStarter launch(Launcher launcher) { return launcher.launch().cmds(toFullArguments()).pwd(pwd); }