Package io.jenkins.plugins.util
Class AbstractExecution<T>
java.lang.Object
org.jenkinsci.plugins.workflow.steps.StepExecution
org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution<T>
io.jenkins.plugins.util.AbstractExecution<T>
- Type Parameters:
T
- the type of the return value (useVoid
if no return value is available)
- All Implemented Interfaces:
Serializable
public abstract class AbstractExecution<T>
extends org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution<T>
Base class for step executions. Provides several helper methods to obtain the defined
context
elements.- Author:
- Ullrich Hafner
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractExecution
(org.jenkinsci.plugins.workflow.steps.StepContext context) Creates a new instance ofAbstractExecution
. -
Method Summary
Modifier and TypeMethodDescriptionprotected ResultHandler
Creates aResultHandler
that sets build result of theRun
or stage.protected StageResultHandler
Deprecated.protected FilePath
Returns Jenkins' build folder.protected Optional
<hudson.remoting.VirtualChannel> Returns aVirtualChannel
to the agent where this step has been executed.protected Charset
getCharset
(String charset) Returns the default charset for the specified encoding string.protected Run
<?, ?> getRun()
Returns the associated pipeline run.protected TaskListener
Returns theTaskListener
for this execution.protected FilePath
Returns the workspace for this job.Methods inherited from class org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution
blocksRestart, getStatus, onResume, run, start, stop
Methods inherited from class org.jenkinsci.plugins.workflow.steps.StepExecution
applyAll, applyAll, getContext, getStatusBounded
-
Constructor Details
-
AbstractExecution
protected AbstractExecution(org.jenkinsci.plugins.workflow.steps.StepContext context) Creates a new instance ofAbstractExecution
.- Parameters:
context
- the context to use
-
-
Method Details
-
getRun
Returns the associated pipeline run.- Returns:
- the run
- Throws:
IOException
- if the run could not be resolvedInterruptedException
- if the user canceled the run
-
getChannel
protected Optional<hudson.remoting.VirtualChannel> getChannel() throws IOException, InterruptedExceptionReturns aVirtualChannel
to the agent where this step has been executed.- Returns:
- the channel
- Throws:
IOException
- if the computer could not be resolvedInterruptedException
- if the user canceled the run
-
getBuildFolder
Returns Jenkins' build folder.- Returns:
- the build folder
- Throws:
IOException
- if the build folder could not be resolvedInterruptedException
- if the user canceled the run
-
getWorkspace
Returns the workspace for this job. If the workspace does not yet exist, then the required folders are created.- Returns:
- the workspace
- Throws:
IOException
- if the workspace could not be resolvedInterruptedException
- if the user canceled the execution
-
getTaskListener
Returns theTaskListener
for this execution.- Returns:
- the task listener (or a silent listener if no task listener could be found)
- Throws:
InterruptedException
- if the user canceled the executionIOException
- if the task listener could not be resolved
-
getCharset
Returns the default charset for the specified encoding string. If the default encoding is empty ornull
, or if the charset is not valid, then the default encoding of the platform is returned.- Parameters:
charset
- identifier of the character set- Returns:
- the default charset for the specified encoding string
-
createStageResultHandler
@Deprecated protected StageResultHandler createStageResultHandler() throws InterruptedException, IOExceptionDeprecated.usecreateResultHandler()
insteadCreates aStageResultHandler
that sets the overall build result of theRun
.- Returns:
- a
StageResultHandler
that sets the overall build result of theRun
- Throws:
InterruptedException
- if the user canceled the executionIOException
- if the requiredFlowNode
instance is not found
-
createResultHandler
Creates aResultHandler
that sets build result of theRun
or stage.- Returns:
- a
ResultHandler
that sets the build result of theRun
or stage - Throws:
InterruptedException
- if the user canceled the executionIOException
- if the requiredFlowNode
instance is not found
-
createResultHandler()
instead