Package net.sourceforge.cruisecontrol.util

Examples of net.sourceforge.cruisecontrol.util.Commandline


            throw new CruiseControlException("'file' is required for ClearCaseBootstrapper");
        }
    }

    protected Commandline buildUpdateCommand() {
        Commandline commandLine = new Commandline();
        commandLine.setExecutable("cleartool");

        commandLine.createArgument().setValue("update");
        commandLine.createArgument().setValue("-force");
        commandLine.createArgument().setValue("-log");
        commandLine.createArgument().setValue(isWindows() ? "NUL" : "/dev/nul");
        commandLine.createArgument().setValue(getFullPathFileName());

        return commandLine;
    }
View Full Code Here


        ValidationHelper.assertNotEmpty(user, "P4User", this.getClass());
        ValidationHelper.assertNotEmpty(passwd, "P4Passwd", this.getClass());
    }

    public void bootstrap() throws CruiseControlException {
        Commandline commandline = createCommandline();
        LOG.debug("Executing commandline [" + commandline + "]");
        executeCommandLine(commandline);
    }
View Full Code Here

        executeCommandLine(commandline);
    }

    public Commandline createCommandline() throws CruiseControlException {
        validate();
        Commandline cmd = new Commandline();
        cmd.setExecutable("p4");
        cmd.createArgument().setValue("-s");
        if (port != null) {
            cmd.createArgument().setValue("-p");
            cmd.createArgument().setValue(port);
        }
        if (client != null) {
            cmd.createArgument().setValue("-c");
            cmd.createArgument().setValue(client);
        }
        if (user != null) {
            cmd.createArgument().setValue("-u");
            cmd.createArgument().setValue(user);
        }
        if (passwd != null) {
            cmd.createArgument().setValue("-P");
            cmd.createArgument().setValue(passwd);
        }
        cmd.createArgument().setValue("sync");
        cmd.createArgument().setValue(view);

        return cmd;
    }
View Full Code Here

     *
     * @param workingDir  The directory to run the script from.
     * @param script  The details on the script to be run.
     */
    public boolean runScript(File workingDir, Script script, long timeout) throws CruiseControlException {
        Commandline commandline = script.buildCommandline();

        commandline.setWorkingDir(workingDir);
       
        Process p;
        int exitCode = -1;

        try {
            p = commandline.execute();
        } catch (IOException e) {
            throw new CruiseControlException("Encountered an IO exception while attempting to execute '"
                    + script.toString() + "'. CruiseControl cannot continue.", e);
        }

View Full Code Here

    public void setFiles(String files) {
        filenames = files;
    }

    public void bootstrap() {
        Commandline args = buildCheckoutCommand();
        int retVal = StarTeamCmd.run(args.getCommandline());
        if (retVal != 0) {
            log.error("Error executing StarTeam checkout command");
        }
    }
View Full Code Here

            return;
        }
    }

    private Commandline buildCheckoutCommand() {
        Commandline commandLine = new Commandline();
        commandLine.createArgument().setValue("co");
        commandLine.createArgument().setValue("-p");
        commandLine.createArgument().setValue(
            username
                + ':'
                + password
                + '@'
                + servername
                + ':'
                + serverport
                + '/'
                + projectname
                + '/'
                + viewname
                + '/'
                + foldername);
        if (localfoldername != null) {
            commandLine.createArgument().setValue("-fp");
            commandLine.createArgument().setValue(localfoldername);
        }
        commandLine.createArgument().setValue("-o");
        commandLine.createArgument().setLine(filenames);
        return commandLine;
    }
View Full Code Here

        List modifications = new ArrayList();
        try {
            String headRevision = getHeadRevision();
            properties.put("svn.revision", headRevision);

            Commandline command = buildHistoryCommand(lastBuild, headRevision);
            modifications = execHistoryCommand(command, lastBuild);
        } catch (Exception e) {
            LOG.error("Error executing svn log command", e);
        }
        return modifications;
View Full Code Here

    }

    private String getHeadRevision()
            throws CruiseControlException, InterruptedException, IOException, ParseException, JDOMException {
        String headRevision = "HEAD";
        Commandline command = buildHistoryCommand(null, headRevision);
        List revisionCheck = execHistoryCommand(command, null);

        if (revisionCheck.size() == 0) {
            LOG.error("Unable to determine HEAD revision (svn.revision will be set to 'HEAD')");
        } else {
View Full Code Here

     * For example:
     *
     * 'svn log --non-interactive --xml -v -r {lastbuildTime}:headRevision repositoryLocation'
     */
    Commandline buildHistoryCommand(Date lastBuild, String headRevision) 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");
        if (lastBuild == null) {
            command.createArgument().setValue("HEAD:COMMITTED");
        } else {
            command.createArgument().setValue(
                "{" + SVN_DATE_FORMAT_IN.format(lastBuild) + "}" + ":" + headRevision);
        }
        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

    /**
     * Update the specified file from the subversion repository.
     */
    public void bootstrap() {
        try {
            Commandline commandLine = buildUpdateCommand();
            execUpdateCommand(commandLine);
        } catch (Exception e) {
            LOG.error("Error executing svn update command", e);
        }
    }
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.