public abstract class TaskListenerDecorator extends Object implements 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 master-side configuration should thus be saved into instance fields when the decorator is constructed.
Modifier and Type | Class and Description |
---|---|
static interface |
TaskListenerDecorator.Factory
Allows a decorator to be applied to any build.
|
Constructor and Description |
---|
TaskListenerDecorator() |
Modifier and Type | Method and Description |
---|---|
static hudson.model.BuildListener |
apply(hudson.model.TaskListener listener,
FlowExecutionOwner owner,
TaskListenerDecorator mainDecorator)
Wraps a logger in a supplied decorator as well as any available from
TaskListenerDecorator.Factory s. |
abstract OutputStream |
decorate(OutputStream logger)
Apply modifications to a build log.
|
static TaskListenerDecorator |
fromConsoleLogFilter(hudson.console.ConsoleLogFilter filter)
Tries to translate a similar core interface into the new API.
|
static TaskListenerDecorator |
merge(TaskListenerDecorator original,
TaskListenerDecorator subsequent)
Merges two decorators.
|
@Nonnull public abstract OutputStream decorate(@Nonnull OutputStream logger) throws IOException, InterruptedException
LineTransformationOutputStream
.logger
- a base loggerIOException
InterruptedException
@Nullable public static TaskListenerDecorator merge(@CheckForNull TaskListenerDecorator original, @CheckForNull TaskListenerDecorator subsequent)
original
- the original decorator, if anysubsequent
- an overriding decorator, if anyoriginal
or subsequent
, or a merged result applying one then the other@CheckForNull public static TaskListenerDecorator fromConsoleLogFilter(@CheckForNull hudson.console.ConsoleLogFilter filter)
The filter may implement either ConsoleLogFilter.decorateLogger(AbstractBuild, OutputStream)
and/or ConsoleLogFilter.decorateLogger(Run, OutputStream)
,
but only ConsoleLogFilter.decorateLogger(AbstractBuild, OutputStream)
will be called, and with a null build
parameter.
The filter must be Serializable
, and furthermore must not assume that JenkinsJVM.isJenkinsJVM()
:
the same constraints as for TaskListenerDecorator
generally.
filter
- a filter, or nullSerializable
public static hudson.model.BuildListener apply(@Nonnull hudson.model.TaskListener listener, @Nonnull FlowExecutionOwner owner, @CheckForNull TaskListenerDecorator mainDecorator)
TaskListenerDecorator.Factory
s.
Does not apply ConsoleLogFilter.all()
even via fromConsoleLogFilter(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.
listener
- the main loggerowner
- a buildmainDecorator
- an additional contextual decorator to apply, if anylistener
Copyright © 2016–2020. All rights reserved.