Package hudson.util
Class StreamTaskListener
- java.lang.Object
-
- hudson.util.AbstractTaskListener
-
- hudson.util.StreamTaskListener
-
- All Implemented Interfaces:
TaskListener
,Closeable
,Serializable
,AutoCloseable
,org.jenkinsci.remoting.SerializableOnlyOverRemoting
- Direct Known Subclasses:
StreamBuildListener
public class StreamTaskListener extends AbstractTaskListener implements TaskListener, Closeable
TaskListener
that generates output into a single stream.This object is remotable.
- Author:
- Kohsuke Kawaguchi
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface hudson.model.TaskListener
NULL
-
-
Constructor Summary
Constructors Constructor Description StreamTaskListener()
Deprecated.as of 1.349 UseTaskListener.NULL
StreamTaskListener(File out)
Deprecated.as of TODO The caller should useStreamTaskListener(File, Charset)
to pass in the charset and file separately, so that this class can handle encoding correctly.StreamTaskListener(File out, boolean append, Charset charset)
Constructs aStreamTaskListener
that sends the output to a specified file.StreamTaskListener(File out, Charset charset)
StreamTaskListener(OutputStream out)
Deprecated.as of TODO The caller should useStreamTaskListener(OutputStream, Charset)
to pass in the charset and output stream separately, so that this class can handle encoding correctly, or usefromStdout()
orfromStderr()
.StreamTaskListener(OutputStream out, Charset charset)
StreamTaskListener(PrintStream out)
Deprecated.as of 1.349 The caller should useStreamTaskListener(OutputStream, Charset)
to pass in the charset and output stream separately, so that this class can handle encoding correctly, or usefromStdout()
orfromStderr()
.StreamTaskListener(Writer w)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
closeQuietly()
Closes this listener and swallows any exceptions, if raised.static StreamTaskListener
fromStderr()
static StreamTaskListener
fromStdout()
Charset
getCharset()
A charset to use for methods returningPrintWriter
.PrintStream
getLogger()
This writer will receive the output of the build-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jenkinsci.remoting.SerializableOnlyOverRemoting
getChannelForSerialization
-
Methods inherited from interface hudson.model.TaskListener
annotate, error, error, fatalError, fatalError, hyperlink
-
-
-
-
Constructor Detail
-
StreamTaskListener
@Deprecated public StreamTaskListener(@NonNull PrintStream out)
Deprecated.as of 1.349 The caller should useStreamTaskListener(OutputStream, Charset)
to pass in the charset and output stream separately, so that this class can handle encoding correctly, or usefromStdout()
orfromStderr()
.
-
StreamTaskListener
@Deprecated public StreamTaskListener(@NonNull OutputStream out)
Deprecated.as of TODO The caller should useStreamTaskListener(OutputStream, Charset)
to pass in the charset and output stream separately, so that this class can handle encoding correctly, or usefromStdout()
orfromStderr()
.
-
StreamTaskListener
public StreamTaskListener(@NonNull OutputStream out, @CheckForNull Charset charset)
-
StreamTaskListener
@Deprecated public StreamTaskListener(@NonNull File out) throws IOException
Deprecated.as of TODO The caller should useStreamTaskListener(File, Charset)
to pass in the charset and file separately, so that this class can handle encoding correctly.- Throws:
IOException
-
StreamTaskListener
public StreamTaskListener(@NonNull File out, @CheckForNull Charset charset) throws IOException
- Throws:
IOException
-
StreamTaskListener
public StreamTaskListener(@NonNull File out, boolean append, @CheckForNull Charset charset) throws IOException
Constructs aStreamTaskListener
that sends the output to a specified file.- Parameters:
out
- the file.append
- iftrue
, then output will be written to the end of the file rather than the beginning.charset
- if non-null
then the charset to use when writing.- Throws:
IOException
- if the file could not be opened.- Since:
- 1.651
-
StreamTaskListener
public StreamTaskListener(@NonNull Writer w) throws IOException
- Throws:
IOException
-
StreamTaskListener
@Deprecated public StreamTaskListener() throws IOException
Deprecated.as of 1.349 UseTaskListener.NULL
- Throws:
IOException
-
-
Method Detail
-
fromStdout
public static StreamTaskListener fromStdout()
-
fromStderr
public static StreamTaskListener fromStderr()
-
getLogger
public PrintStream getLogger()
Description copied from interface:TaskListener
This writer will receive the output of the build- Specified by:
getLogger
in interfaceTaskListener
-
getCharset
public Charset getCharset()
Description copied from interface:TaskListener
A charset to use for methods returningPrintWriter
. Should match that used to constructTaskListener.getLogger()
.- Specified by:
getCharset
in interfaceTaskListener
- Returns:
- by default, UTF-8
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
closeQuietly
public void closeQuietly()
Closes this listener and swallows any exceptions, if raised.- Since:
- 1.349
-
-