Java 类hudson.tasks.CommandInterpreter 实例源码

项目:Spirent-iTest-Jenkins-Plugin    文件:ITest.java   
/**
 * Generate iTAR files using iTestCLI. 
 * 
 * @param project
 * @param build
 * @param launcher
 * @param listener
 */
private boolean canGenerateITARFile(final String project, 
        final AbstractBuild<?, ?> build, 
        final Launcher launcher, final BuildListener listener) { 

    //--exportProject accepts multiple projects separated 
    //by comma but not spaces 

    String path = parseWorkspace(build); 
    String generateITAR = itestcli + " --workspace " + path
            + " --exportPath " + path + " --exportProject " 
            + project.replaceAll("\\s+",""); 

    CommandInterpreter runner = 
            getCommandInterpreter(launcher, generateITAR); 

    try { 
        runner.perform(build, launcher, listener);
    } catch (Exception e) { 
        e.printStackTrace();
    }

    return consoleOutputIsValid(build); 
}
项目:jenkinslint-plugin    文件:HardcodedScriptChecker.java   
private boolean isBuilderHarcoded (List<Builder> builders) {
    boolean found = false;
    if (builders != null && builders.size() > 0 ) {
        for (Builder builder : builders) {
            if (builder instanceof hudson.tasks.Shell || builder instanceof hudson.tasks.BatchFile) {
                if (isHarcoded (((CommandInterpreter)builder).getCommand(), THRESHOLD)) {
                    found = true;
                }
            }
        }
    } else {
        found = false;
    }
    return found;
}
项目:Spirent-iTest-Jenkins-Plugin    文件:ITest.java   
/**
 * Run iTestRT commands. 
 * 
 * @param command
 * @param build
 * @param launcher
 * @param listener
 */
private boolean buildSucceeds(final String command, final AbstractBuild<?, ?> build, 
        final Launcher launcher, final BuildListener listener) { 

    String uniformPathSeparators = command.replaceAll("\\\\", "/"); 
    CommandInterpreter runner = 
            getCommandInterpreter(launcher, uniformPathSeparators); 
    try {
        runner.perform(build, launcher, listener);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    return consoleOutputIsValid(build); 
}
项目:Spirent-iTest-Jenkins-Plugin    文件:ITest.java   
/**
 * Return correct CommandInterpreter based on OS  
 * 
 * @param launcher
 * @param script
 * @return CommandInterpreter
 */
private CommandInterpreter getCommandInterpreter(final Launcher launcher,
        final String script) {
    if (launcher.isUnix())
        return new Shell(script);
    else
        return new BatchFile(script);
}
项目:jenkins-inheritance-plugin    文件:InheritanceViewAction.java   
private boolean dumpBuildSteps(
        List<Builder> builders,
        List<File> generatedScripts,
        File srcDir
) throws IOException {
    boolean isLinux = true;
    int i = 0;
    for (Builder builder : builders) {
        if (!(builder instanceof CommandInterpreter)) {
            continue;
        }
        CommandInterpreter ci = (CommandInterpreter) builder;
        File builderScript;
        if (builder instanceof BatchFile) {
            isLinux = false;
            builderScript = new File(srcDir, String.format("step_%d.bat", i++));
        } else {
            builderScript = new File(srcDir, String.format("step_%d.sh", i++));
        }

        BufferedWriter out = new BufferedWriter(
                new FileWriter(builderScript, true)
        );
        String cmd = ci.getCommand();
        if (!isLinux) {
            //Ensure windows line-endings
            cmd = cmd.replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
        }
        out.write(cmd);
        builderScript.setExecutable(true, false);
        builderScript.setReadable(true, false);
        builderScript.setWritable(true, false);
        out.close();
        generatedScripts.add(builderScript);
    }
    return isLinux;
}