Class TaskListenerDecorator
- java.lang.Object
-
- org.jenkinsci.plugins.workflow.log.TaskListenerDecorator
-
- All Implemented Interfaces:
Serializable
public abstract class TaskListenerDecorator extends Object implements Serializable
A way of decorating output from aTaskListener
. Similar toConsoleLogFilter
but better matched to Pipeline logging.May be passed to a
BodyInvoker
in lieu ofBodyInvoker.mergeConsoleLogFilters(hudson.console.ConsoleLogFilter, hudson.console.ConsoleLogFilter)
, usingmerge(org.jenkinsci.plugins.workflow.log.TaskListenerDecorator, org.jenkinsci.plugins.workflow.log.TaskListenerDecorator)
to pick up any earlier decorator inStepContext.get(java.lang.Class<T>)
.Expected to be serializable either locally or over Remoting, so an implementation of
decorate(java.io.OutputStream)
cannot assume thatJenkinsJVM.isJenkinsJVM()
. Any controller-side configuration should thus be saved into instance fields when the decorator is constructed.- See Also:
- JENKINS-45693, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TaskListenerDecorator.Factory
Allows a decorator to be applied to any build.
-
Constructor Summary
Constructors Constructor Description TaskListenerDecorator()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static BuildListener
apply(TaskListener listener, FlowExecutionOwner owner, TaskListenerDecorator mainDecorator)
Wraps a logger in a supplied decorator as well as any available fromTaskListenerDecorator.Factory
s.abstract OutputStream
decorate(OutputStream logger)
Apply modifications to a build log.static TaskListenerDecorator
fromConsoleLogFilter(ConsoleLogFilter filter)
Tries to translate a similar core interface into the new API.static TaskListenerDecorator
merge(TaskListenerDecorator original, TaskListenerDecorator subsequent)
Merges two decorators.
-
-
-
Method Detail
-
decorate
@NonNull public abstract OutputStream decorate(@NonNull OutputStream logger) throws IOException, InterruptedException
Apply modifications to a build log. Typical implementations useLineTransformationOutputStream
.- Parameters:
logger
- a base logger- Returns:
- a possibly patched result
- Throws:
IOException
InterruptedException
-
merge
@Nullable public static TaskListenerDecorator merge(@CheckForNull TaskListenerDecorator original, @CheckForNull TaskListenerDecorator subsequent)
Merges two decorators.- Parameters:
original
- the original decorator, if anysubsequent
- an overriding decorator, if any- Returns:
- null, or
original
orsubsequent
, or a merged result applying one then the other
-
fromConsoleLogFilter
@CheckForNull public static TaskListenerDecorator fromConsoleLogFilter(@CheckForNull ConsoleLogFilter filter)
Tries to translate a similar core interface into the new API.The filter may implement either
ConsoleLogFilter.decorateLogger(AbstractBuild, OutputStream)
and/orConsoleLogFilter.decorateLogger(Run, OutputStream)
, but onlyConsoleLogFilter.decorateLogger(AbstractBuild, OutputStream)
will be called, and with a nullbuild
parameter.The filter must be
Serializable
, and furthermore must not assume thatJenkinsJVM.isJenkinsJVM()
: the same constraints as forTaskListenerDecorator
generally.- Parameters:
filter
- a filter, or null- Returns:
- an adapter, or null if it is null or (after issuing a warning) not
Serializable
- See Also:
- JEP-210: Backwards Compatibility
-
apply
public static BuildListener apply(@NonNull TaskListener listener, @NonNull FlowExecutionOwner owner, @CheckForNull TaskListenerDecorator mainDecorator)
Wraps a logger in a supplied decorator as well as any available fromTaskListenerDecorator.Factory
s.Does not apply
ConsoleLogFilter.all()
even viafromConsoleLogFilter(hudson.console.ConsoleLogFilter)
, since there is no mechanical way to tell if implementations actually satisfy the constraints. Anyway these singletons could not determine which build they are being applied to if remoted.- Parameters:
listener
- the main loggerowner
- a buildmainDecorator
- an additional contextual decorator to apply, if any- Returns:
- a possibly wrapped
listener
-
-