Package hudson.Launcher

Examples of hudson.Launcher.LocalLauncher


        StreamTaskListener task = new StreamTaskListener(baos);
        task.getLogger().println("Restarting a service");
        File executable = new File(home, "hudson.exe");
        if (!executable.exists())   executable = new File(home, "jenkins.exe");

        int r = new LocalLauncher(task).launch().cmds(executable, "restart")
                .stdout(task).pwd(home).join();
        if(r!=0)
            throw new IOException(baos.toString());
    }
View Full Code Here


        out.println("Migration completed");
        return true;
    }

    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();
    }
View Full Code Here

     * <p>
     * If it fails in a way that indicates the presence of UAC, retry in an UAC compatible manner.
     */
    static int runElevated(File slaveExe, String command, TaskListener out, File pwd) throws IOException, InterruptedException {
        try {
            return new LocalLauncher(out).launch().cmds(slaveExe, command).stdout(out).pwd(pwd).join();
        } catch (IOException e) {
            if (e.getMessage().contains("CreateProcess") && e.getMessage().contains("=740")) {
                // fall through
            } else {
                throw e;
View Full Code Here

            else // in production code this never happens, but during debugging this is convenientud   
                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);
View Full Code Here

                FileUtils.copyURLToFile(getClass().getResource("list"),exe);
                LIBC.chmod(exe.getAbsolutePath(),0755);

                ByteArrayOutputStream out = new ByteArrayOutputStream();
                int exit = new LocalLauncher(listener).launch().cmds(exe).stdout(out).stderr(logger).join();
                if (exit!=0) {
                    logger.println(exe + " failed to execute:" + exit);
                    logger.write(out.toByteArray());
                    logger.println();
                    return Collections.emptyList();
View Full Code Here

            }

            ArgumentListBuilder arguments = new ArgumentListBuilder(fruitstrap.getRemote());
            arguments.add("--id", deviceId, "--bundle", appDir.getName());

            ProcStarter proc = new LocalLauncher(listener).launch()
                    .cmds(arguments)
                    .stdout(listener)
                    .pwd(appDir.getParent());
            int exit = proc.join();
            if (exit!=0)
View Full Code Here

        this.workspace = workspace;
        this.listener = listener;
        this.gitExe = gitExe;
        this.environment = environment;
        launcher = new LocalLauncher(GitSCM.VERBOSE ? listener : TaskListener.NULL);

        if (hasGitRepo()) {//Wrap file repository if exists in order to perform operations and initialize jGitDelegate
            try {
                File gitDir = RepositoryCache.FileKey.resolve(new File(workspace.getRemote()), FS.DETECTED);
                jGitDelegate = Git.wrap(new FileRepositoryBuilder().setGitDir(gitDir).build());
View Full Code Here

    /**
     * Runs svnserve to serve the specified directory as a subversion repository.
     */
    protected Proc runSvnServe(File repo) throws Exception {
        LocalLauncher launcher = new LocalLauncher(StreamTaskListener.fromStdout());
        try {
            launcher.launch().cmds("svnserve","--help").start().join();
        } catch (IOException e) {
          Assert.fail("Failed to launch svnserve. Do you have subversion installed?\n" + e);
        }

        // If there is an already existing svnserve running on the machine
        // We need to fail the build. We could change this to if the port is in use, listen to different port
        Socket s = null;
        ServerSocket serverSocket = null;
        int port = 3690; // Default svnserve port is 3690.
        try {
          s = new Socket("localhost", 3690);
          // If it gets this far, that means that it is able to send/receive information.
          // Since the default svnserve port is currently in use, fail the build.
          System.err.println("Port 3690 is currently in use. Using a random port.");
          serverSocket = new ServerSocket(0);
          port = serverSocket.getLocalPort();
          serverSocket.close();
        } catch (IOException e) {
          // Port is not in use
        } finally {
          if (s != null) {
            s.close();
          }
        }

        return launcher.launch().cmds(
                "svnserve","-d","--foreground","-r",repo.getAbsolutePath(), "--listen-port", String.valueOf(port)).pwd(repo).start();
    }
View Full Code Here

            this.err = err;
            this.workDir = workDir;
            this.listener = listener;
        }
        public Integer call() throws IOException {
            Launcher.ProcStarter ps = new LocalLauncher(listener).launch();
            ps.cmds(cmd).envs(env).stdin(in).stdout(out);
            if(err != null) ps.stderr(err);
            if(workDir!=null)   ps.pwd(workDir);

            Proc p;
View Full Code Here

        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());
    }
View Full Code Here

TOP

Related Classes of hudson.Launcher.LocalLauncher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.