Class DiagnosticScanner
java.lang.Object
java.io.OutputStream
hudson.console.LineTransformationOutputStream
io.jenkins.plugins.dotnet.console.DiagnosticScanner
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Scanner to detect diagnostic messages (warnings and errors) in the output of .NET commands.
Also sees the error/warning summary lines for MSBuild-based commands and sets properties to the respective counts.
It currently uses hardcoded 'Error(s)' and 'Warning(s)' strings, so if the node has a non-English language configured, the processing will likely fail. It may be enough to have a few well-known alternatives for these string, but assumptions about message format and word order may still cause problems.
-
Nested Class Summary
Nested classes/interfaces inherited from class hudson.console.LineTransformationOutputStream
LineTransformationOutputStream.Delegating
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this scanner; this forces end-of-line processing and then closes the wrapped output stream.protected void
eol
(byte[] lineBytes, int lineLength) Scans a line of output, then forwards it to the wrapped output stream.void
flush()
Flushes the wrapped output stream.int
Gets the number of errors reported by an MSBuild-based command in its build summary.int
Gets the number of warnings reported by an MSBuild-based command in its build summary.void
writeCompletionMessage
(int rc) Writes the command completion message to the stream wrapped by this scanner.Methods inherited from class hudson.console.LineTransformationOutputStream
forceEol, trimEOL, write, write
Methods inherited from class java.io.OutputStream
write
-
Constructor Details
-
DiagnosticScanner
Creates a new scanner.- Parameters:
out
- The output stream to decorate.charset
- The character set in use.
-
-
Method Details
-
getErrors
public int getErrors()Gets the number of errors reported by an MSBuild-based command in its build summary.- Returns:
- The number of errors reported; 0 if no build summary was seen.
-
getWarnings
public int getWarnings()Gets the number of warnings reported by an MSBuild-based command in its build summary.- Returns:
- The number of warnings reported; 0 if no build summary was seen.
-
close
Closes this scanner; this forces end-of-line processing and then closes the wrapped output stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classLineTransformationOutputStream
- Throws:
IOException
- When thrown by eitherLineTransformationOutputStream.close()
orOutputStream.close()
.
-
flush
Flushes the wrapped output stream.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- When thrown byOutputStream.flush()
.
-
eol
Scans a line of output, then forwards it to the wrapped output stream.- Specified by:
eol
in classLineTransformationOutputStream
- Parameters:
lineBytes
- The raw line contents, including any line terminator.lineLength
- The length of the line withinlineBytes
.- Throws:
IOException
- When thrown byOutputStream.write(byte[], int, int)
.
-
writeCompletionMessage
public void writeCompletionMessage(int rc) Writes the command completion message to the stream wrapped by this scanner. This uses a specific marker (COMPLETION_MESSAGE_EXIT_CODE_MARKER
) in order to add separate markup for the message text and the return code information.- Parameters:
rc
- The command's return code.
-