Skip to content
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

avoid logging empty lines, so removing complete log lines becomes possible #2

Merged
merged 5 commits into from
Nov 5, 2021

Conversation

TorstenKruse
Copy link

So far it was not possible to completly filter log lines. Even when the regex matched to complete line, the plugin still logged an empty line, so the build log contains many, many empty lines.
With this PR empty lines won't be logged any more, so build logs become cleaner.

@amandel
Copy link
Member

amandel commented Oct 20, 2021

@TorstenKruse thanks for this. The 1 makes me unsure a bit. This might behave different on different platforms? Can you check for only white space content?

@TorstenKruse
Copy link
Author

@amandel Like this?

@amandel
Copy link
Member

amandel commented Oct 23, 2021

Not quiet, wow all modified lines containing a white space are removed. Since we are on java 8, what about iterating though the characters of the line and see if there is no isWhitespace in. Looking at my quick check it might be the case that writing an empty string in this case might not be sufficient, a following \n might also need to be swallowed.

@TorstenKruse
Copy link
Author

I don't understand your comment. All lines containing at least one non-whitespace char are printed. This does not implicate that all lines with a whitespace are removed. :)

We have the patch already running in our jenkins and the logs are fine as expected - which means only the lines which contain only whitespace chars are removed.

So please re-check the code and perhaps try it out yourself. ;)

@TorstenKruse
Copy link
Author

BTW: Looks like the complete plugin does work for freestyle and maven jobs, but not for pipeline. Or am I missing something?

@amandel
Copy link
Member

amandel commented Oct 28, 2021

I did a test on windows with simple echos using hpi:run. All lines that have a matching pattern just vanish, independent if there are remaining characters or not. Not sure what the difference is between your and my setup.

To use the logFileFilter in the pipeline simply surround the code:

...
logFileFilter {
   ...
   echo 'Test secret.'
   ...
}
...

I'll add this to the documentation.

@amandel amandel added the enhancement New feature or request label Oct 28, 2021
@TorstenKruse
Copy link
Author

You are right. Looks like the old line endings story on windows vs. linux. I enhanced the regexp to allow \r and \n. Please try again.

Adding info about pipeline usage to the documentation sounds good.

But in my view one of the key features of logFileFilter is its global usage. Just activate in jenkins setting, define some regex and it works for all jobs out of the box.

Instead of this the need to add a "logFileFilter {}" to all pipelines...for hundred of jobs...that not what I would like to get. ;)
Do you see any solution to get it running for pipelines the same as for "normal" jobs?

@amandel
Copy link
Member

amandel commented Nov 5, 2021

Do you see any solution to get it running for pipelines the same as for "normal" jobs?

As I remember this was not possible at the time of writing the plugin two years ago. Actually there is (was?) no default log file filtering at all. Might be this changed, I do not know :( .

@amandel amandel merged commit 43e83b7 into jenkinsci:master Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants