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 void
configure(JobContext jobCtx, CommandService aCommandService)
protected void
configure(Run<?,?> aRun, FilePath aWorkspace, Launcher aLauncher, TaskListener aTaskListener, CommandService aCommandService)
void
executeCommands()
CommandService
getCommandService()
CommandState
getCommandState()
Get the command state for the associated completed command.abstract IBaseCommandData
getDataForCommand(ICommand command)
EnvVars
getEnvVars()
When running from pipeline, the result returned fromRun.getEnvironment(TaskListener)
won't include the system environments set by theenv.VAR=value
orwithEnv(['VAR=value'])
.JobContext
getJobContext()
CommandState
getLastCommandState()
Get the command state for the last command being executed.void
logError(Exception ex)
void
logError(String message)
void
logError(String prefix, Exception ex)
void
logStatus(String status)
void
setCommandState(CommandState commandState)
Set the command state for the associated running command.void
setLastCommandState(CommandState lastCommandState)
Set the command state for the last command being executed in the command service.org.jenkinsci.plugins.workflow.steps.StepExecution
start(org.jenkinsci.plugins.workflow.steps.StepContext context)
Pipeline function call entrance.abstract org.jenkinsci.plugins.workflow.steps.StepExecution
startImpl(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 Exception
Pipeline function call entrance.- Specified by:
start
in 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=value
orwithEnv(['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
Run
as normal.- Specified by:
getEnvVars
in interfaceIBaseCommandData
-
executeCommands
public void executeCommands()
-
getDataForCommand
public abstract IBaseCommandData getDataForCommand(ICommand command)
- Specified by:
getDataForCommand
in interfaceICommandServiceData
-
setCommandState
public void setCommandState(CommandState commandState)
Description copied from interface:IBaseCommandData
Set the command state for the associated running command.- Specified by:
setCommandState
in interfaceIBaseCommandData
- Parameters:
commandState
- the result command state.
-
getCommandState
public CommandState getCommandState()
Description copied from interface:IBaseCommandData
Get the command state for the associated completed command.- Specified by:
getCommandState
in interfaceIBaseCommandData
- Returns:
- the result command state.
-
getLastCommandState
public CommandState getLastCommandState()
Description copied from interface:ICommandServiceData
Get the command state for the last command being executed. This will be the state of the command service execution.- Specified by:
getLastCommandState
in interfaceICommandServiceData
- See Also:
IBaseCommandData.getCommandState()
-
setLastCommandState
public void setLastCommandState(CommandState lastCommandState)
Description copied from interface:ICommandServiceData
Set the command state for the last command being executed in the command service.- Specified by:
setLastCommandState
in interfaceICommandServiceData
- Parameters:
lastCommandState
- the last command state.- See Also:
IBaseCommandData.setCommandState(CommandState)
-
getCommandService
public CommandService getCommandService()
- Specified by:
getCommandService
in interfaceICommandServiceData
-
getJobContext
public final JobContext getJobContext()
- Specified by:
getJobContext
in interfaceIBaseCommandData
-
logStatus
public void logStatus(String status)
- Specified by:
logStatus
in interfaceIBaseCommandData
-
logError
public void logError(Exception ex)
- Specified by:
logError
in interfaceIBaseCommandData
-
logError
public void logError(String prefix, Exception ex)
- Specified by:
logError
in interfaceIBaseCommandData
-
logError
public void logError(String message)
- Specified by:
logError
in interfaceIBaseCommandData
-
-