-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#185 Add RunListener.onFinalized listener. Inject START ActionNote #198
Conversation
…onNote after build finishes to trigger plugin's logic also on partial log output
So you're now altering the log files? What could go wrong? :) |
Well, "altering" seems so ominous. Obviously the very worst scenario is a completely messed up log file and Jenkins not able to show it. I did think about that and I am doing the changes in a separate log copy and only substituting the original one in the last few lines (reverting the substitution in case of exceptions while doing it) - if anything goes wrong along the way the original log stays intact. While thinking about alternatives what would essentially be needed in order to fix this bug is:
For Point no.1 we could maybe look into the actual log line and do something like:
which might be problematic (what if some build tool also starts their logs with "Starting"). Do you see any other alternatives? |
…orizedAction to indicate shortlog ansicolor begin
…an be used more broadly and is backwards serializable
…og coloring to kick-in
…preparing additional action used in shortlog
…ore shortlog position. Add tests
Since manually updating the log file is not without risk of destroying the thing I took a bit cautious approach and managed to implement triggering the plugin in a shortlog without it. This implementation still reads the whole log after the build but doesn't update it in any way. Instead it adds an additional I consider the work done (functions and tests are there) but of course - I'm open to improvement suggestions. |
Nice job! |
Fixes #185
During a log rendering, the business logic for
ansicolor
is enabled byActionNote
s serialized directly in the log file. If you open only the lastx
Bytes of the log it very likely won't contain any STARTColorizedAction
s (there can be multiple ones) so the plugin will stay inactive.If we inject an additional START
ActionNote
atx
Bytes from the end of the log we will be able to trigger the functionality at just the right moment without affecting anything else. The problem is that you don't know the actual log size before the build has finished and when it does theOutputStream
has obviously moved far beyond the injection point.What this PR proposes is:
RunListener.onFinalized
eventColorizedAction
should be active at theend - x
Byte markActionNote
The general idea already works. There are still a couple of
todos
and I also want to cover this with tests.Constructive criticism would be welcome.