Package net.sourceforge.cruisecontrol.util

Examples of net.sourceforge.cruisecontrol.util.Commandline


      * in New York, CruiseControl in San Francisco).  A negative offset
      * indicates that the Perforce server time is before the CruiseControl
      * server.
      */
    protected long calculateServerTimeOffset() throws IOException {
        Commandline command = new Commandline();
        command.setExecutable("p4");
        command.createArgument().setValue("info");

        LOG.debug("Executing: " + command.toString());
        LOG.info(command.toString());
        Process p = Runtime.getRuntime().exec(command.getCommandline());
        logErrorStream(p.getErrorStream());
        long offset = parseServerInfo(p.getInputStream());

        return offset;
    }
View Full Code Here


        return offset;
    }


    private Commandline buildBaseP4Command() {
        Commandline commandLine = new Commandline();
        commandLine.setExecutable("p4");
        commandLine.createArgument().setValue("-s");

        if (p4Client != null) {
            commandLine.createArgument().setValue("-c");
            commandLine.createArgument().setValue(p4Client);
        }

        if (p4Port != null) {
            commandLine.createArgument().setValue("-p");
            commandLine.createArgument().setValue(p4Port);
        }

        if (p4User != null) {
            commandLine.createArgument().setValue("-u");
            commandLine.createArgument().setValue(p4User);
        }

        if (p4Passwd != null) {
            commandLine.createArgument().setValue("-P");
            commandLine.createArgument().setValue(p4Passwd);
        }
        return commandLine;
    }
View Full Code Here

            }
        }
    }

    protected String[] getCommandLine(Date lastBuild, Date now) throws CruiseControlException {
        Commandline commandline = new Commandline();
        String execCommand;
        try {
            execCommand = (ssDir != null) ? new File(ssDir, "ss.exe").getCanonicalPath() : "ss.exe";
        } catch (IOException e) {
            throw new CruiseControlException(e);
        }

        commandline.setExecutable(execCommand);
        commandline.createArgument().setValue("history");
        commandline.createArgument().setValue(vssPath);
        commandline.createArgument().setValue("-R");
        commandline.createArgument().setValue("-Vd" + formatDateForVSS(now) + "~" + formatDateForVSS(lastBuild));
        commandline.createArgument().setValue("-Y" + login);
        commandline.createArgument().setValue("-I-N");
        commandline.createArgument().setValue("-O" + getTempFile().getName());

        String[] line = commandline.getCommandline();

        LOG.debug(" ");
        for (int i = 0; i < line.length; i++) {
            LOG.debug("Vss command line arguments: " + line[i]);
        }
View Full Code Here

     * If CVSROOT/users doesn't exist, an empty Hashtable is returned.
     */
    private Hashtable getMailAliases() {
        if (mailAliases == null) {
            mailAliases = new Hashtable();
            Commandline commandLine = new Commandline();
            commandLine.setExecutable("cvs");

            if (cvsroot != null) {
                commandLine.createArgument().setValue("-d");
                commandLine.createArgument().setValue(cvsroot);
            }
           
            commandLine.createArgument().setLine("-q co -p CVSROOT/users");

            Process p = null;
            try {
                if (local != null) {
                    commandLine.setWorkingDirectory(local);
                }
           
                p = commandLine.execute();
                logErrorStream(p);
                InputStream is = p.getInputStream();
                BufferedReader in = new BufferedReader(new InputStreamReader(is));

                String line;
View Full Code Here

     * @param lastBuildTime
     * @param checkTime
     * @return CommandLine for "cvs -d CVSROOT -q log -N -dlastbuildtime<checktime "
     */
    public Commandline buildHistoryCommand(Date lastBuildTime, Date checkTime) throws CruiseControlException {
        Commandline commandLine = new Commandline();
        commandLine.setExecutable("cvs");

        if (local != null) {
            commandLine.setWorkingDirectory(local);
        }
        if (cvsroot != null) {
            commandLine.createArgument().setValue("-d");
            commandLine.createArgument().setValue(cvsroot);
        }
        commandLine.createArgument().setValue("-q");

        commandLine.createArgument().setValue("log");
        commandLine.createArgument().setValue("-N");
        String dateRange = formatCVSDate(lastBuildTime) + "<" + formatCVSDate(checkTime);
        commandLine.createArgument().setValue("-d" + dateRange);

        if (tag != null) {
            // add -b and -rTAG to list changes relative to the current branch,
            // not relative to the default branch, which is HEAD

            // note: -r cannot have a space between itself and the tag spec.
            commandLine.createArgument().setValue("-r" + tag);
        } else {
            // This is used to include the head only if a Tag is not specified.
            commandLine.createArgument().setValue("-b");
        }

        return commandLine;
    }
View Full Code Here

    }

    public void publish(Element cruisecontrolLog)
        throws CruiseControlException {

        Commandline command = new Commandline(commandString);
        LOG.info("executing command: " + command);

        try {
            Runtime.getRuntime().exec(command.getCommandline());
        } catch (IOException e) {
            throw new CruiseControlException(e);
        }
    }
View Full Code Here

        if (file == null) {
            XMLLogHelper helper = new XMLLogHelper(cruisecontrolLog);
            file = helper.getLogFileName().substring(1);
        }

        Commandline command = createCommandline(file);
        LOG.info("executing command: " + command);
        try {
            Runtime.getRuntime().exec(command.getCommandline());
        } catch (IOException e) {
            throw new CruiseControlException(e);
        }
    }
View Full Code Here

    public Commandline createCommandline(String file) {
        String sourcefile = File.separator + file;
        String targetfile = targetSeparator + file;

        Commandline command = new Commandline();
        command.setExecutable("scp");
        command.createArgument().setLine(options);
        command.createArgument().setValue("-S");
        command.createArgument().setValue(ssh);

        createFileArgument(
            command.createArgument(),
            sourceUser,
            sourceHost,
            sourceDir,
            sourcefile);

        createFileArgument(
            command.createArgument(),
            targetUser,
            targetHost,
            targetDir,
            targetfile);
View Full Code Here

            }
        }
    }

    protected String[] getCommandLine(Date lastBuild, Date now) throws CruiseControlException {
        Commandline commandline = new Commandline();
        String execCommand = null;
        try {
            execCommand = (ssDir != null) ? new File(ssDir, "ss.exe").getCanonicalPath() : "ss.exe";
        } catch (IOException e) {
            throw new CruiseControlException(e);
        }
       
        commandline.setExecutable(execCommand);
        commandline.createArgument().setValue("history");
        commandline.createArgument().setValue(vssPath);
        commandline.createArgument().setValue("-R");
        commandline.createArgument().setValue("-Vd" + formatDateForVSS(now) + "~" + formatDateForVSS(lastBuild));
        commandline.createArgument().setValue("-Y" + login);
        commandline.createArgument().setValue("-I-N");
        commandline.createArgument().setValue("-O" + VSS_TEMP_FILE);

        String[] line = commandline.getCommandline();

        LOG.debug(" ");
        for (int i = 0; i < line.length; i++) {
            LOG.debug("Vss command line arguments: " + line[i]);
        }
View Full Code Here

            bwr.close();
        } catch (IOException ioex) {
            fail("Unexpected IOException while preparing " + filename + " test file");
        }
        if (!onWindows) {
            Commandline cmdline = new Commandline();
            cmdline.setExecutable("chmod");
            cmdline.createArgument().setValue("755");
            cmdline.createArgument().setValue(testFile.getAbsolutePath());
            try {
                Process p = cmdline.execute();      
                p.waitFor();        
            } catch (Exception e) {
                e.printStackTrace();
                fail("exception changing permissions on test file " + testFile.getAbsolutePath());
            }
View Full Code Here

TOP

Related Classes of net.sourceforge.cruisecontrol.util.Commandline

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.