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
[JENKINS-69907] Suppress logging with optional param #1416
Conversation
plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/IssuesRecorder.java
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/PublishIssuesStep.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/PublishIssuesStep.java
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/PublishIssuesStep.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/RecordIssuesStep.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/analysis/core/util/LogHandler.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/analysis/core/util/LogHandler.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/analysis/core/util/LogHandler.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/analysis/core/util/LogHandler.java
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #1416 +/- ##
============================================
+ Coverage 79.87% 79.88% +0.01%
- Complexity 1452 1461 +9
============================================
Files 252 252
Lines 5594 5622 +28
Branches 424 425 +1
============================================
+ Hits 4468 4491 +23
- Misses 976 981 +5
Partials 150 150
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks almost good now! Thanks for improving.
One little thing would be helpful: Change one of the tests in StepsITest
so that it runs one time with quite
and one time without. And then check the console log accordingly. (Example in test shouldSkipBlaming
)
plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/IssuesRecorder.java
Outdated
Show resolved
Hide resolved
ui-tests/src/main/java/io/jenkins/plugins/analysis/warnings/IssuesRecorder.java
Outdated
Show resolved
Hide resolved
@uhafner many thx for support! I'd possibly need one more hint, here is wrong assumption. Not sure what would be best...
|
+ " }\n" | ||
+ "}", true)); | ||
Run<?, ?> baseline = buildSuccessfully(job); | ||
assertThat(getConsoleLog(baseline)).hasSize(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no way to suppress or work on the whole log. I think you simply should
assertThat(getConsoleLog(baseline)).doesNotContain("Searching for all files in");
You can also use a ParameterizedTest
with a ValueSource(booleans = {true, false}
and then use the same test:
if (isQuite) {
assertThat(getConsoleLog(baseline)).doesNotContain("Searching for all files in");
}
else {
assertThat(getConsoleLog(baseline)).contains("Searching for all files in");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I get it right, does console log really contains LogHandler
output or its feeded separately without LogHandler
? Whatever I've tried console contained all content.
Also, the other option add & check new log line would make it not completely muted (not a big issue, but...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed now, there was still one method left that had no guard. Now the guard is at the lowest method in the call stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
thank you! 👍 |
Thanks for your pull request! This is a much more versatile approach as the first one. I will extract the main parts of this PR to apply the same pattern for my other plugins (code coverage). |
Goal: reduce console output in jenkins job when printing file name and num of issues found.
Change: introduced new param
quiet
to mute logging.See: JENKINS-69907
Comments for initial suggestion with sysproperty - #1403