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()); }
Proc p = vmb.launch(new LocalLauncher(listener)).stdout(listener).pwd(workDir).start();
/** * Returns true if the executable exists. */ public boolean getExists() { try { return getExecutable(new LocalLauncher(new StreamTaskListener(new NullStream())))!=null; } catch (IOException | InterruptedException e) { return false; } }
/** * Returns true if the executable exists. */ public boolean getExists() { try { return getExecutable(new LocalLauncher(new StreamTaskListener(new NullStream())))!=null; } catch (IOException e) { return false; } catch (InterruptedException e) { return false; } }
/** * Creates {@link hudson.Launcher.LocalLauncher}. Useful for launching processes. */ public Launcher.LocalLauncher createLocalLauncher() { return new Launcher.LocalLauncher(StreamTaskListener.fromStdout()); }
/** * Returns true if the executable exists. */ public boolean getExists() throws IOException, InterruptedException { return getExecutable(new Launcher.LocalLauncher(TaskListener.NULL))!=null; }
protected void assumeDocker() throws Exception { Launcher.LocalLauncher localLauncher = new Launcher.LocalLauncher(StreamTaskListener.NULL); try { Assume.assumeThat("Docker working", localLauncher.launch().cmds(DockerTool.getExecutable(null, null, null, null), "ps").join(), is(0)); } catch (IOException x) { Assume.assumeNoException("have Docker installed", x); } DockerClient dockerClient = new DockerClient(localLauncher, null, null); Assume.assumeFalse("Docker version not < 1.3", dockerClient.version().isOlderThan(new VersionNumber("1.3"))); }
/** * Creates a {@link Launcher} for starting processes on the node * that has this file. * @since 1.89 */ public Launcher createLauncher(TaskListener listener) throws IOException, InterruptedException { if(channel==null) return new LocalLauncher(listener); else return new RemoteLauncher(listener,channel,channel.call(new IsUnix())); }
/** * Creates {@link LocalLauncher}. Useful for launching processes. */ protected LocalLauncher createLocalLauncher() { return new LocalLauncher(StreamTaskListener.fromStdout()); }
/** * Returns true if the executable exists. */ public boolean getExists() throws IOException, InterruptedException { return getExecutable(new Launcher.LocalLauncher(TaskListener.NULL))!=null; }
@Override public void restart() throws IOException, InterruptedException { File me = getHudsonWar(); File home = me.getParentFile(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamTaskListener task = new StreamTaskListener(baos); task.getLogger().println("Restarting a service"); int r = new LocalLauncher(task).launch().cmds(new File(home, "hudson.exe"), "restart") .stdout(task).pwd(home).join(); if(r!=0) throw new IOException(baos.toString()); }
@Override public void restart() throws IOException, InterruptedException { File me = getHudsonWar(); File home = me.getParentFile(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamTaskListener task = new StreamTaskListener(baos); task.getLogger().println("Restarting a service"); int r = new LocalLauncher(task).launch().cmds(new File(home, "hudson.exe"), "restart") .stdout(task).pwd(home).join(); if(r!=0) throw new IOException(baos.toString()); }
/** * Creates {@link LocalLauncher}. Useful for launching processes. */ protected LocalLauncher createLocalLauncher() { return new LocalLauncher(StreamTaskListener.fromStdout()); }
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) {
VirtualChannel start(TaskListener listener, String rootPassword) throws IOException, InterruptedException { final int uid = LIBC.geteuid(); if(uid==0) // already running as root return newLocalChannel(); String javaExe = System.getProperty("java.home") + "/bin/java"; File slaveJar = Which.jarFile(Launcher.class); ArgumentListBuilder args = new ArgumentListBuilder().add(javaExe); if(slaveJar.isFile()) args.add("-jar").add(slaveJar); else // in production code this never happens, but during debugging this is convenient args.add("-cp").add(slaveJar).add(hudson.remoting.Launcher.class.getName()); if(rootPassword==null) { // try sudo, in the hope that the user has the permission to do so without password return new LocalLauncher(listener).launchChannel( args.prepend(sudoExe()).toCommandArray(), listener.getLogger(), null, Collections.<String, String>emptyMap()); } else { // try sudo with the given password. Also run in pfexec so that we can elevate the privileges Process proc = sudoWithPass(args); return Channels.forProcess(args.toStringWithQuote(), Computer.threadPoolForRemoting, proc, listener.getLogger() ); } } }
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 Launcher createLauncher(TaskListener listener) { return new LocalLauncher(listener).decorateFor(this); }
/** * Creates a {@link Launcher} for starting processes on the node * that has this file. * @since 1.89 */ public Launcher createLauncher(TaskListener listener) throws IOException, InterruptedException { if(channel==null) return new LocalLauncher(listener); else return new RemoteLauncher(listener,channel,channel.call(new IsUnix())); }
/** * Returns true if the executable exists. */ public boolean getExists() { try { return getExecutable(new LocalLauncher(new StreamTaskListener(new NullStream())))!=null; } catch (IOException | InterruptedException e) { return false; } }