jenkinsci / ansicolor-plugin

Jenkins ANSI Color Plugin
https://plugins.jenkins.io/ansicolor/
MIT License
252 stars 82 forks source link

Disable Empty new lines before and after ANSI Color Block #255

Open 296951 opened 1 year ago

296951 commented 1 year ago

What feature do you want to see added?

When I use the ansi color plugin I get an empty log line before and after EVERY ANSI color block in the log.

Is there a way to disable this?

image

The json block is one ansi color block.

The 4 individual lines are each an ansi color block

Notice all the new lines Below is the same log section with color disabled:

image

Upstream changes

No response

dblock commented 1 year ago

Looks like a bug, doesn't it? I would try to reproduce in a unit test next.

tszmytka commented 1 year ago

The new lines are the main part of a workaround that allows ansicolor to have its work actually passed on to the log file in the presence of timestamper plugin. Here's more info.

296951 commented 1 year ago

Is there a way to change the behavior if timestamper is not being used? I still get extra lines even if it is not used.

tszmytka commented 1 year ago

Is there a way to change the behavior if timestamper is not being used? I still get extra lines even if it is not used.

The determining factor here is whether the other extension (timestamper) is installed, not if it's being used currently (there's no reliable way of checking that).

lemeurherve commented 1 year ago

The determining factor here is whether the other extension (timestamper) is installed, not if it's being used currently (there's no reliable way of checking that).

TIL, bummer.

Could a global env var or a setting configurable on the controller by admins could be a way of controlling this as a workaround?

Or a coordinate fix like you suggested in https://github.com/jenkinsci/ansicolor-plugin/issues/193#issuecomment-657233610?

Will read more about it in the several linked issues... Interested as I'd like to get this plugin running properly on infra.ci.jenkins.io with timestamps activated globally without modifying every pipelines.

hashar commented 1 year ago

With Ansicolor 0.7.5 I don't have any newlines added when the color map is set globally. If I enable it at the job level, the extra newline shows up.

Ansicolor 1.0.0 has:

Based on the description of #218, TERM was not set for the global config. I thus imagine this change adding TERM leads to the newlines to be inserted. But maybe it is unrelated.

There is also e603edc33e7ca71ae5f2959e7a26d53d47103def (released in Ansicolor 0.7.3) which apparently cause a newline to be added when there is a decorator timestamper.pipeline.GlobalDecorator or kubernetes.pipeline.SecretsMasker.

lppedd commented 10 months ago

@tszmytka was the way timestamper works ever fixed? I recall you mentioning that the root problem was indeed how timestamper uses the log.

reubenavery commented 4 months ago

I am experiencing the exact opposite of this behavior in ANSI Reset codes causing lines to drop the \r returns and run together instead. 2024-05-14 at 2 04 PM 2024-05-14 at 2 02 PM