Package jenkins.tasks
Interface SimpleBuildStep
- All Superinterfaces:
BuildStep
- All Known Implementing Classes:
ArtifactArchiver
,Fingerprinter
A build step (like a
Builder
or Publisher
) which may be called at an arbitrary time during a build (or multiple times), run, and be done.
Such a build step would typically be written according to some guidelines that ensure it makes few assumptions about how it is being used:
- Do not implement
BuildStep.prebuild(hudson.model.AbstractBuild<?, ?>, hudson.model.BuildListener)
, since this presupposes a particular execution order. - Do not implement
BuildStep.getProjectActions(hudson.model.AbstractProject<?, ?>)
, since this might never be called if the step is not part of the static configuration of a project; instead, add aSimpleBuildStep.LastBuildAction
to a build when run. - Implement
BuildStep.getRequiredMonitorService()
to beBuildStepMonitor.NONE
, since this facility only makes sense for a step called exactly once per build. - Do not implement
DependencyDeclarer
since this would be limited to use inAbstractProject
. - Return true unconditionally from
BuildStepDescriptor.isApplicable(java.lang.Class<? extends hudson.model.AbstractProject>)
(there is currently no filtering for otherJob
types). - Do not expect
Executor.currentExecutor()
to be non-null, and by extension do not useComputer.currentComputer()
.
- Since:
- 1.577
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Marker for explicitly added build actions (asRun.addAction(hudson.model.Action)
) which should imply a transient project action (Actionable.getActions()
) when present on theJob.getLastSuccessfulBuild()
.static final class
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherList
-
Field Summary
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
perform
(Run<?, ?> run, EnvVars env, TaskListener listener) Run this step, without a workspace context.default void
Run this step.default void
perform
(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) Deprecated.default boolean
Determines whether or not this step requires a workspace context (working directory and launcher).Methods inherited from interface hudson.tasks.BuildStep
getProjectAction, getProjectActions, getRequiredMonitorService, perform, prebuild
-
Method Details
-
perform
@Deprecated default void perform(@NonNull Run<?, ?> run, @NonNull FilePath workspace, @NonNull Launcher launcher, @NonNull TaskListener listener) throws InterruptedException, IOExceptionDeprecated.Run this step.- Parameters:
run
- a build this is running as a part ofworkspace
- a workspace to use for any file operationslauncher
- a way to start processeslistener
- a place to send output- Throws:
InterruptedException
- if the step is interruptedIOException
- if something goes wrong; useAbortException
for a polite error
-
perform
default void perform(@NonNull Run<?, ?> run, @NonNull FilePath workspace, @NonNull EnvVars env, @NonNull Launcher launcher, @NonNull TaskListener listener) throws InterruptedException, IOExceptionRun this step.This method must be overridden when this step requires a workspace context. If such a context is not required, it does not need to be overridden; it will then forward to
perform(Run, EnvVars, TaskListener)
.- Parameters:
run
- a build this is running as a part ofworkspace
- a workspace to use for any file operationsenv
- environment variables applicable to this steplauncher
- a way to start processeslistener
- a place to send output- Throws:
AbstractMethodError
- if this step requires a workspace context and neither this method norperform(Run, FilePath, Launcher, TaskListener)
is overriddenInterruptedException
- if the step is interruptedIOException
- if something goes wrong; useAbortException
for a polite error- Since:
- 2.241
-
perform
default void perform(@NonNull Run<?, ?> run, @NonNull EnvVars env, @NonNull TaskListener listener) throws InterruptedException, IOExceptionRun this step, without a workspace context.This method must be overridden when this step does not require a workspace context, and will not be called when such a context is required.
- Parameters:
run
- a build this is running as a part ofenv
- environment variables applicable to this steplistener
- a place to send output- Throws:
AbstractMethodError
- if this method is not overriddenIllegalStateException
- if this step requires a workspace contextInterruptedException
- if the step is interruptedIOException
- if something goes wrong; useAbortException
for a polite error- Since:
- 2.258
-
requiresWorkspace
default boolean requiresWorkspace()Determines whether or not this step requires a workspace context (working directory and launcher).When such a context is required (the default),
perform(Run, FilePath, EnvVars, Launcher, TaskListener)
applies. Otherwise,perform(Run, EnvVars, TaskListener)
applies.- Returns:
true
if this step requires a workspace context;false
otherwise.- Since:
- 2.258
-
perform(Run, FilePath, EnvVars, Launcher, TaskListener)
instead.