我试图去掉我的詹金斯输出。感谢Is it possible to capture the stdout from the sh DSL command in the pipeline,我知道我可以将每个sh命令的输出发送到一个文件。但是,命令本身仍然会写入Jenkins输出而不是文件。例如:是否可以将Jenkins管道中的sh DSL命令的所有输出发送到文件?
sh '''echo "Hello World!"
./helloworld
./seeyoulater
'''
原样,这导致詹金斯输出看起来像这样:
echo "Hello World!"
Hello World!
./helloworld
<helloworld output, possibly many lines>
./seeyoulater
<seeyoulater output, possibly many lines>
但是,如果我将输出发送到一个文件,我得到这样詹金斯输出:
echo "Hello World!" > output.log
./helloworld >> output.log
./seeyoulater >> output.log
和output.log看起来像这样:
Hello World!
<helloworld output>
<seeyoulater output>
这会导致我的Jenkins输出不那么混乱,但output.log最终在脚本输出之间没有任何分隔符。我想我可以在每个命令之前有echo <command>
,但这只意味着我的詹金斯输出再次变得混乱。
有什么办法可以将sh
DSL命令的整个输出发送到文件吗?基本上像sh '''<commands here>''' > output.log
是我正在寻找的东西。