I like to keep my build logs very neat and tidy by only displaying the most important information. Sometimes I have to use a step that blurts out a ton of information to the build log. I would like to be able to silence steps on demand.
I have tried the following from my shared library but it didn’t work.
@NonCPS
void noOutput() {
PrintStream stream = new PrintStream(new File('/dev/null')
System.setOut(stream)
}
also…
@NonCPS
void noOutput() {
LogManager manager = LogManager.getLogManager()
manager.reset()
}
When I used these in a job…
println('visible')
myLogger.noOutput()
println('not visible')
But both were still visible =/
If you have a way I can disable build output and then re-enable it, then would love to hear about it.
I’m thinking of something like…
println('visible')
build.silent {
println('NOT visible')
}
and also having a DEBUG environment variable that would print stuff even in the silent block.