Class BaseCommandContext
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<org.jenkinsci.plugins.workflow.steps.Step>
-
- org.jenkinsci.plugins.workflow.steps.Step
-
- com.microsoft.jenkins.azurecommons.command.BaseCommandContext
-
- All Implemented Interfaces:
IBaseCommandData,ICommandServiceData,ExtensionPoint,Describable<org.jenkinsci.plugins.workflow.steps.Step>
public abstract class BaseCommandContext extends org.jenkinsci.plugins.workflow.steps.Step implements ICommandServiceData, IBaseCommandData
A mixed abstract base class with both command data and command service data.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description BaseCommandContext()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidconfigure(JobContext jobCtx, CommandService aCommandService)protected voidconfigure(Run<?,?> aRun, FilePath aWorkspace, Launcher aLauncher, TaskListener aTaskListener, CommandService aCommandService)voidexecuteCommands()CommandServicegetCommandService()CommandStategetCommandState()Get the command state for the associated completed command.abstract IBaseCommandDatagetDataForCommand(ICommand command)EnvVarsgetEnvVars()When running from pipeline, the result returned fromRun.getEnvironment(TaskListener)won't include the system environments set by theenv.VAR=valueorwithEnv(['VAR=value']).JobContextgetJobContext()CommandStategetLastCommandState()Get the command state for the last command being executed.voidlogError(Exception ex)voidlogError(String message)voidlogError(String prefix, Exception ex)voidlogStatus(String status)voidsetCommandState(CommandState commandState)Set the command state for the associated running command.voidsetLastCommandState(CommandState lastCommandState)Set the command state for the last command being executed in the command service.org.jenkinsci.plugins.workflow.steps.StepExecutionstart(org.jenkinsci.plugins.workflow.steps.StepContext context)Pipeline function call entrance.abstract org.jenkinsci.plugins.workflow.steps.StepExecutionstartImpl(org.jenkinsci.plugins.workflow.steps.StepContext context)
-
-
-
Method Detail
-
configure
protected void configure(Run<?,?> aRun, FilePath aWorkspace, Launcher aLauncher, TaskListener aTaskListener, CommandService aCommandService)
-
configure
protected void configure(JobContext jobCtx, CommandService aCommandService)
-
start
public final org.jenkinsci.plugins.workflow.steps.StepExecution start(org.jenkinsci.plugins.workflow.steps.StepContext context) throws ExceptionPipeline function call entrance.- Specified by:
startin classorg.jenkinsci.plugins.workflow.steps.Step- Parameters:
context- the pipeline step context- Returns:
- the execution logic object.
- Throws:
Exception
-
startImpl
public abstract org.jenkinsci.plugins.workflow.steps.StepExecution startImpl(org.jenkinsci.plugins.workflow.steps.StepContext context) throws Exception- Throws:
Exception
-
getEnvVars
public EnvVars getEnvVars()
When running from pipeline, the result returned fromRun.getEnvironment(TaskListener)won't include the system environments set by theenv.VAR=valueorwithEnv(['VAR=value']). We need to callStepContext.get(EnvVar.class)for the full environment variables set.If the field is not null, we are running from pipeline and we use this as the source of environment variables; otherwise we fetch the environment variables from
Runas normal.- Specified by:
getEnvVarsin interfaceIBaseCommandData
-
executeCommands
public void executeCommands()
-
getDataForCommand
public abstract IBaseCommandData getDataForCommand(ICommand command)
- Specified by:
getDataForCommandin interfaceICommandServiceData
-
setCommandState
public void setCommandState(CommandState commandState)
Description copied from interface:IBaseCommandDataSet the command state for the associated running command.- Specified by:
setCommandStatein interfaceIBaseCommandData- Parameters:
commandState- the result command state.
-
getCommandState
public CommandState getCommandState()
Description copied from interface:IBaseCommandDataGet the command state for the associated completed command.- Specified by:
getCommandStatein interfaceIBaseCommandData- Returns:
- the result command state.
-
getLastCommandState
public CommandState getLastCommandState()
Description copied from interface:ICommandServiceDataGet the command state for the last command being executed. This will be the state of the command service execution.- Specified by:
getLastCommandStatein interfaceICommandServiceData- See Also:
IBaseCommandData.getCommandState()
-
setLastCommandState
public void setLastCommandState(CommandState lastCommandState)
Description copied from interface:ICommandServiceDataSet the command state for the last command being executed in the command service.- Specified by:
setLastCommandStatein interfaceICommandServiceData- Parameters:
lastCommandState- the last command state.- See Also:
IBaseCommandData.setCommandState(CommandState)
-
getCommandService
public CommandService getCommandService()
- Specified by:
getCommandServicein interfaceICommandServiceData
-
getJobContext
public final JobContext getJobContext()
- Specified by:
getJobContextin interfaceIBaseCommandData
-
logStatus
public void logStatus(String status)
- Specified by:
logStatusin interfaceIBaseCommandData
-
logError
public void logError(Exception ex)
- Specified by:
logErrorin interfaceIBaseCommandData
-
logError
public void logError(String prefix, Exception ex)
- Specified by:
logErrorin interfaceIBaseCommandData
-
logError
public void logError(String message)
- Specified by:
logErrorin interfaceIBaseCommandData
-
-