jenkins.plugins.shiningpanda.command
Class Command

java.lang.Object
  extended by jenkins.plugins.shiningpanda.command.Command
Direct Known Subclasses:
PythonCommand, ShellCommand

public abstract class Command
extends Object


Constructor Summary
protected Command(String command, boolean ignoreExitCode)
          Constructor using fields.
 
Method Summary
protected  hudson.FilePath createScriptFile(hudson.FilePath dir)
          Create content of the script execute.
static Command get(boolean isUnix, String executable, CommandNature nature, String command, boolean ignoreExitCode)
          Get the right command executor.
protected abstract  hudson.util.ArgumentListBuilder getArguments(hudson.FilePath script)
          Get the command line to execute.
protected  String getCommand()
          Get the content of the script to execute.
protected abstract  String getContents()
          Get the content of the script file
protected  hudson.EnvVars getEnvironment(hudson.FilePath pwd, hudson.EnvVars environment)
          Be able to have a late environment processing.
protected abstract  String getExtension()
          Get the extension of the script file.
protected  boolean isExitCodeIgnored()
          Is the exit code ignored?
 boolean launch(hudson.Launcher launcher, hudson.model.TaskListener listener, hudson.EnvVars environment, hudson.FilePath pwd)
          Launch the command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Command

protected Command(String command,
                  boolean ignoreExitCode)
Constructor using fields.

Parameters:
command - The content of the execution script
ignoreExitCode - Is exit code ignored?
Method Detail

getCommand

protected String getCommand()
Get the content of the script to execute.

Returns:
The content of the script to execute

isExitCodeIgnored

protected boolean isExitCodeIgnored()
Is the exit code ignored?

Returns:
true of exit code is ignored, else false

getExtension

protected abstract String getExtension()
Get the extension of the script file.

Returns:
The extension

getContents

protected abstract String getContents()
Get the content of the script file

Returns:
The content of the file

getArguments

protected abstract hudson.util.ArgumentListBuilder getArguments(hudson.FilePath script)
Get the command line to execute.

Parameters:
script - The script to execute
Returns:
The arguments

getEnvironment

protected hudson.EnvVars getEnvironment(hudson.FilePath pwd,
                                        hudson.EnvVars environment)
Be able to have a late environment processing.

Parameters:
pwd - The working directory
environment - The environment
Returns:
The processed environment

createScriptFile

protected hudson.FilePath createScriptFile(hudson.FilePath dir)
                                    throws IOException,
                                           InterruptedException
Create content of the script execute.

Parameters:
dir - The folder in which the script is created
Returns:
The script file
Throws:
IOException
InterruptedException

launch

public boolean launch(hudson.Launcher launcher,
                      hudson.model.TaskListener listener,
                      hudson.EnvVars environment,
                      hudson.FilePath pwd)
               throws InterruptedException
Launch the command.

Parameters:
launcher - The launcher
listener - The listener
environment - The environment
pwd - The current directory
Returns:
true if successful, else false
Throws:
InterruptedException

get

public static Command get(boolean isUnix,
                          String executable,
                          CommandNature nature,
                          String command,
                          boolean ignoreExitCode)
Get the right command executor.

Parameters:
isUnix - Target execution platform
executable - The PYTHON executable
nature - The nature of the command: PYTHON, shell, X shell
command - The content of the script to execute
ignoreExitCode - Is exit code ignored?
Returns:
The command object


Copyright © 2004-2012. All Rights Reserved.