Package net.sourceforge.cruisecontrol.util

Examples of net.sourceforge.cruisecontrol.util.Commandline


     * @return the list of modifications, or an empty list if we failed
     * to retrieve the changes.
     */
    public List getModifications(Date lastBuild, Date now) {
        List modifications = new ArrayList();
        Commandline command;
        try {
            command = buildHistoryCommand(lastBuild, now);
        } catch (CruiseControlException e) {
            LOG.error("Error building history command", e);
            return modifications;
View Full Code Here


     * For example:
     *
     * 'svn log --non-interactive --xml -v -r {lastbuildTime}:headRevision repositoryLocation'
     */
    Commandline buildHistoryCommand(Date lastBuild, Date checkTime) throws CruiseControlException {
        Commandline command = new Commandline();
        command.setExecutable("svn");

        if (localWorkingCopy != null) {
            command.setWorkingDirectory(localWorkingCopy);
        }

        command.createArgument().setValue("log");
        command.createArgument().setValue("--non-interactive");
        command.createArgument().setValue("--xml");
        command.createArgument().setValue("-v");
        command.createArgument().setValue("-r");
        command.createArgument().setValue("{" + formatSVNDate(lastBuild) + "}" + ":"
                + "{" + formatSVNDate(checkTime) + "}");

        if (userName != null) {
            command.createArgument().setValue("--username");
            command.createArgument().setValue(userName);
        }
        if (password != null) {
            command.createArgument().setValue("--password");
            command.createArgument().setValue(password);
        }
        if (repositoryLocation != null) {
            command.createArgument().setValue(repositoryLocation);
        }

        LOG.debug("Executing command: " + command);

        return command;
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 = getCommandline();
        commandLine.setExecutable("cvs");

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

        if (local != null) {
            commandLine.setWorkingDirectory(local);
            commandLine.createArgument().setValue("log");
        } else {
            commandLine.createArgument().setValue("rlog");
        }
       
        boolean useHead = tag == null || tag.equals(CVS_HEAD_TAG) || tag.equals("");
        if (useHead) {
            commandLine.createArgument().setValue("-N");
        }
        String dateRange = formatCVSDate(lastBuildTime) + "<" + formatCVSDate(checkTime);
        commandLine.createArgument().setValue("-d" + dateRange);

        if (!useHead) {
            // 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");
        }

        if (local == null) {
            commandLine.createArgument().setValue(module);
        }

        return commandLine;
    }
View Full Code Here

        return commandLine;
    }

    // factory method for mock...
    protected Commandline getCommandline() {
        return new Commandline();
    }
View Full Code Here

    }

    protected Version getCvsServerVersion() {
        if (cvsServerVersion == null) {

            Commandline commandLine = getCommandline();
            commandLine.setExecutable("cvs");

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

            commandLine.createArgument().setLine("version");

            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));

                cvsServerVersion = extractCVSServerVersionFromCVSVersionCommandOutput(in);
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 = getCommandline();
            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

    }

    private List describeAllChangelistsAndBuildOutput(String[] changelistNumbers)
            throws IOException, InterruptedException {

        Commandline command = buildDescribeCommand(changelistNumbers);
        LOG.info(command.toString());
        Process p = Runtime.getRuntime().exec(command.getCommandline());

        logErrorStream(p.getErrorStream());
        InputStream p4Stream = p.getInputStream();
        List mods = parseChangeDescriptions(p4Stream);
        getRidOfLeftoverData(p4Stream);
View Full Code Here

    }

    private String[] collectChangelistSinceLastBuild(Date lastBuild, Date now)
            throws IOException, InterruptedException {

        Commandline command = buildChangesCommand(lastBuild, now, Util.isWindows());
        LOG.debug("Executing: " + command.toString());
        Process p = Runtime.getRuntime().exec(command.getCommandline());

        logErrorStream(p.getErrorStream());
        InputStream p4Stream = p.getInputStream();

        String[] changelistNumbers = parseChangelistNumbers(p4Stream);
View Full Code Here

        } else {
            LOG.debug("No server time offset determined.");
        }


        Commandline commandLine = buildBaseP4Command();

        commandLine.createArgument().setValue("changes");
        commandLine.createArgument().setValue("-s");
        commandLine.createArgument().setValue("submitted");
        commandLine.createArgument().setValue(p4View
                + "@"
                + P4_REVISION_DATE.format(lastBuildTime)
                + ",@"
                + P4_REVISION_DATE.format(now));
View Full Code Here

    /**
     * p4 -s [-c client] [-p port] [-u user] describe -s [change number]
     */
    public Commandline buildDescribeCommand(String[] changelistNumbers) {
        Commandline commandLine = buildBaseP4Command();

        //        execP4Command("describe -s " + changeNumber.toString(),

        commandLine.createArgument().setValue("describe");
        commandLine.createArgument().setValue("-s");

        for (int i = 0; i < changelistNumbers.length; i++) {
            commandLine.createArgument().setValue(changelistNumbers[ i ]);
        }

        return commandLine;
    }
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.