简体   繁体   English

如何避免Jenkins出现不希望的“动画”控制台输出

[英]How to avoid undesired “animated” console output on Jenkins

Sometimes I find log-lines like these in my Jenkins Job Output: 有时,我在Jenkins Job Output中找到这样的日志行:

 [|]   [/]   [-]   [\]   [|]   [/]   [-]   [\]   [|]   [/]   [-]

I know these lines come from a "Progress Spinner" ( https://askubuntu.com/questions/623933/how-to-create-a-rotation-animation-using-shell-script ) but they look weird in a plain-text log. 我知道这些行来自“ Progress Spinner”( https://askubuntu.com/questions/623933/how-to-create-a-rotation-animation-using-shell-script ),但在纯文本中看起来很奇怪文字记录。

It gets worse, when a tool uses a "command line progress bar" which comes eg when pulling a Docker Image or an NPM package - then the log contains real ugly (and unnecessary) log blocks. 更糟糕的是,当工具使用“命令行进度条”时(例如,拉出Docker Image或NPM软件包时),该日志包含真正的丑陋(且不必要)的日志块。

...
xtracting [=============>                                   ]  15.2 MB/50.31 MB
xtracting [==============>                                  ]  15.2 MB/50.31 MB
xtracting [===============>                                 ]  15.2 MB/50.31 MB
xtracting [================>                                ]  15.2 MB/50.31 MB
xtracting [=================>                               ]  15.2 MB/50.31 MB
----

Is there any Jenkins Plugin existing (like the Ansi-Color Plugin ) which either shows the animation or shrinks the output to the final "position" ? 是否存在任何可以显示动画或将输出缩小到最终“位置”的Jenkins插件(如Ansi-Color插件 )?

I don't want to use every tool in "quiet" mode just to skip these unnecessary "ascii arts" because a lot of interesting information gets lost then. 我不想在“安静”模式下使用所有工具只是为了跳过这些不必要的“ ascii arts”,因为那样会丢失很多有趣的信息。

This is an interesting subject but I am afraid that there is almost nothing safe you can do to "compress" the output if the tool didn't detect the TTY properly. 这是一个有趣的话题,但是如果工具没有正确检测到TTY,恐怕几乎没有安全的方法可以用来“压缩”输出。

Here are the workarounds: 以下是变通办法:

  • Enable a less verbose or quiet mode when you call the tool in order to avoid the progress bars. 调用该工具时,请启用较详细或安静的模式,以避免出现进度条。 Look for switches like -q or --silent 寻找-q--silent类的开关
  • If the tool is still displaying progress bards when you redirect the output to a file, it is a bug and you should file a bug to that tool. 如果在将输出重定向到文件时该工具仍在显示进度条,则表明它是一个错误,您应该向该工具提交一个错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM