Class TaskListenerDecorator
- All Implemented Interfaces:
Serializable
TaskListener.
Similar to ConsoleLogFilter but better matched to Pipeline logging.
May be passed to a BodyInvoker in lieu of BodyInvoker.mergeConsoleLogFilters(hudson.console.ConsoleLogFilter, hudson.console.ConsoleLogFilter),
using merge(org.jenkinsci.plugins.workflow.log.TaskListenerDecorator, org.jenkinsci.plugins.workflow.log.TaskListenerDecorator) to pick up any earlier decorator in StepContext.get(java.lang.Class<T>).
Expected to be serializable either locally or over Remoting,
so an implementation of decorate(java.io.OutputStream) cannot assume that JenkinsJVM.isJenkinsJVM().
Any controller-side configuration should thus be saved into instance fields when the decorator is constructed.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAllows a decorator to be applied to any build. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BuildListenerapply(TaskListener listener, FlowExecutionOwner owner, TaskListenerDecorator mainDecorator) Wraps a logger in a supplied decorator as well as any available fromTaskListenerDecorator.Factorys.abstract OutputStreamdecorate(OutputStream logger) Apply modifications to a build log.static TaskListenerDecoratorfromConsoleLogFilter(ConsoleLogFilter filter) Tries to translate a similar core interface into the new API.static TaskListenerDecoratormerge(TaskListenerDecorator original, TaskListenerDecorator subsequent) Merges two decorators.
-
Constructor Details
-
TaskListenerDecorator
public TaskListenerDecorator()
-
-
Method Details
-
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:
IOExceptionInterruptedException
-
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
originalorsubsequent, 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 nullbuildparameter.The filter must be
Serializable, and furthermore must not assume thatJenkinsJVM.isJenkinsJVM(): the same constraints as forTaskListenerDecoratorgenerally.- Parameters:
filter- a filter, or null- Returns:
- an adapter, or null if it is null or (after issuing a warning) not
Serializable - See Also:
-
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.Factorys.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
-