I'm trying to de-clutter my Jenkins output. Thanks to Is it possible to capture the stdout from the sh DSL command in the pipeline, I know I can send the output of each sh command to a file. However, the commands themselves will still be written to the Jenkins output instead of the file. For example:
sh '''echo "Hello World!"
./helloworld
./seeyoulater
'''
As is, this results in the Jenkins output looking like this:
echo "Hello World!"
Hello World!
./helloworld
<helloworld output, possibly many lines>
./seeyoulater
<seeyoulater output, possibly many lines>
However, if I send the output to a file, I get Jenkins output like this:
echo "Hello World!" > output.log
./helloworld >> output.log
./seeyoulater >> output.log
and output.log looking like this:
Hello World!
<helloworld output>
<seeyoulater output>
This leads to my Jenkins output being less cluttered, but output.log ends up not having any separators between the script outputs. I suppose I could have echo <command>
right before each command, but that just means my Jenkins output gets more cluttered again.
Is there any way to send the entire output of the sh
DSL command to a file? Basically something like sh '''<commands here>''' > output.log
is what I'm looking for.