com.atlassian.bamboo.command
Class Command

java.lang.Object
  extended by com.atlassian.bamboo.command.Command
Direct Known Subclasses:
AbstractBuilder, CVSCommand, GrailsCommand

public abstract class Command
extends java.lang.Object

This class executes a command line command.


Field Summary
protected  BuildLoggerManager buildLoggerManager
           
static java.lang.String CBD_BUILD_COMMANDLINE
          Key name in custom build data
protected  VariableSubstitutionBean substitutionBean
           
 
Constructor Summary
Command()
           
 
Method Summary
protected  void decorateCommandLine(org.apache.tools.ant.types.Commandline commandline, BuildContext context)
           
 int executeCommand(BuildContext buildContext, CommandExecuteStreamHandler commandExecuteStreamHandler, java.lang.String extraEnvironmentVariables, java.lang.String javaHome, ReadOnlyCapabilitySet capabilitySet)
          Execute the command line in a specific directory.
 BuildLoggerManager getBuildLoggerManager()
           
 java.lang.String[] getCommandArguments(ReadOnlyCapabilitySet capabilitySet)
          What are the arguments for the command line to execute Variable substitution is not required for the arguments, substitution will be performed later.
 java.lang.String getCommandExecutable(ReadOnlyCapabilitySet capabilitySet)
          What is the executable for the command line to execute.
 org.apache.tools.ant.types.Commandline getCommandLine(ReadOnlyCapabilitySet capabilitySet)
          Deprecated. 
protected  java.lang.String[] getCustomEnvironmentVars(ReadOnlyCapabilitySet capabilitySet)
           
 java.lang.String[] getEnvironmentSetting(java.lang.String vmParams, java.lang.String javaHome)
          Returns the environment settings.
 org.apache.tools.ant.types.Commandline getSubstitutedCommandLine(BuildContext buildContext, BuildLogger buildLogger, ReadOnlyCapabilitySet capabilitySet)
          Get the command line provided by implementing class and provides variable substitution.
 VariableSubstitutionBean getVariableSubstitutionBean()
           
abstract  java.io.File getWorkingDirectory()
          Where should the command be executed?
protected  boolean isWindowsPlatform()
          Is the server running on the Windows platform?
 void setBuildLoggerManager(BuildLoggerManager buildLoggerManager)
           
 void setPluginAccessor(com.atlassian.plugin.PluginAccessor pluginAccessor)
           
 void setVariableSubstitutionBean(VariableSubstitutionBean substitutionBean)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

substitutionBean

protected VariableSubstitutionBean substitutionBean

buildLoggerManager

protected BuildLoggerManager buildLoggerManager

CBD_BUILD_COMMANDLINE

public static final java.lang.String CBD_BUILD_COMMANDLINE
Key name in custom build data

See Also:
Constant Field Values
Constructor Detail

Command

public Command()
Method Detail

executeCommand

public int executeCommand(@NotNull
                          BuildContext buildContext,
                          @NotNull
                          CommandExecuteStreamHandler commandExecuteStreamHandler,
                          java.lang.String extraEnvironmentVariables,
                          java.lang.String javaHome,
                          ReadOnlyCapabilitySet capabilitySet)
                   throws CommandException
Execute the command line in a specific directory.

Parameters:
buildContext - The BuildContext for the current build
commandExecuteStreamHandler - Stream Handler for the output of the execute command
extraEnvironmentVariables - environment variable additional to those already in the env (e.g provided by the user via UI)
javaHome - The java home value for this command
capabilitySet - Capability set
Returns:
-1 if the command failed
Throws:
CommandException - Failure

decorateCommandLine

protected void decorateCommandLine(org.apache.tools.ant.types.Commandline commandline,
                                   BuildContext context)

getCustomEnvironmentVars

@Nullable
protected java.lang.String[] getCustomEnvironmentVars(ReadOnlyCapabilitySet capabilitySet)

getEnvironmentSetting

public java.lang.String[] getEnvironmentSetting(java.lang.String vmParams,
                                                java.lang.String javaHome)
Returns the environment settings. It combines the standard java settings with those provides in the vmParams

Strips off any preceeding -D's from the start of the settings

Parameters:
vmParams - build specific settings
javaHome - value for JAVA_HOME env setting
Returns:
the settings

getSubstitutedCommandLine

@NotNull
public org.apache.tools.ant.types.Commandline getSubstitutedCommandLine(BuildContext buildContext,
                                                                                BuildLogger buildLogger,
                                                                                ReadOnlyCapabilitySet capabilitySet)
Get the command line provided by implementing class and provides variable substitution.

Parameters:
buildContext - Containing current build specific information
buildLogger - Build specific logger object
capabilitySet - Capability set
Returns:
Substituted command line separated into arguments

getWorkingDirectory

public abstract java.io.File getWorkingDirectory()
Where should the command be executed?

Returns:
The directory in which the command will be run

getCommandLine

@Deprecated
public org.apache.tools.ant.types.Commandline getCommandLine(ReadOnlyCapabilitySet capabilitySet)
Deprecated. 

Deprecated, use getCommandExecutable() and getCommandArguments() instead

Parameters:
capabilitySet - Capability set
Returns:
The command line

getCommandExecutable

@NotNull
public java.lang.String getCommandExecutable(ReadOnlyCapabilitySet capabilitySet)
What is the executable for the command line to execute. Variable substitution is not required for exectutable, substitution will be performed later.

Parameters:
capabilitySet- - for the current context
Returns:
the executable as a string

getCommandArguments

@NotNull
public java.lang.String[] getCommandArguments(ReadOnlyCapabilitySet capabilitySet)
What are the arguments for the command line to execute Variable substitution is not required for the arguments, substitution will be performed later.

Parameters:
capabilitySet - - for the current context
Returns:
the executable as a string[]. Spaces/division of strings in the array should not matter.

isWindowsPlatform

protected boolean isWindowsPlatform()
Is the server running on the Windows platform?

Returns:
true if we're on Windows

setVariableSubstitutionBean

public void setVariableSubstitutionBean(VariableSubstitutionBean substitutionBean)

setPluginAccessor

public void setPluginAccessor(com.atlassian.plugin.PluginAccessor pluginAccessor)

getVariableSubstitutionBean

public VariableSubstitutionBean getVariableSubstitutionBean()

setBuildLoggerManager

public void setBuildLoggerManager(BuildLoggerManager buildLoggerManager)

getBuildLoggerManager

public BuildLoggerManager getBuildLoggerManager()


Copyright © 2010 Atlassian. All Rights Reserved.