TeamCity:写入 stderr 和 stdout 时构建日志中的消息顺序错误
简单的 python 脚本:
for i in range(0, 5):
print "ok"
sys.stderr.write('err\r\n')
在 TeamCity 下执行此脚本(构建步骤)时,“构建日志”选项卡中会出现以下输出:
ok
err
ok
ok
ok
err
ok
err
err
err
消息完全随机顺序错误。
请建议如何使消息按照写入输出的顺序进行。
谢谢。
Simple python script:
for i in range(0, 5):
print "ok"
sys.stderr.write('err\r\n')
When executing this script under TeamCity (build step), following output appears in Build Log tab:
ok
err
ok
ok
ok
err
ok
err
err
err
Messages go in wrong completely random order.
Please suggest how to make messages go in same order they are written to output.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个已知问题,请加注星标/投票。
It's a known issue, please star/vote.
如果您只想写入 stdout 和 stderr 来区分消息和错误,您可以尝试使用服务消息: http://confluence.jetbrains.net/display/TCD65/Build+Script+Interaction+with+TeamCity。他们仅使用一种渠道来区分不同的消息,并且不会以错误的顺序传递。
If you only want to write to stdout and stderr to distinguish between messages and errors, you could try to use service messages: http://confluence.jetbrains.net/display/TCD65/Build+Script+Interaction+with+TeamCity. They are using only one channel to distinguish different messages and do not go in wrong order.
以下是 bash 脚本的部分解决方法:
现在您至少可以在重要命令之前和之后同步
stdout
和stderr
:在此更改之前,TeamCity 可以在某些行之后显示打印的 bash 命令通过该命令打印。
Here is a partial workaround for bash scripts:
Now you can synchronize
stdout
andstderr
at least before and after important commands:Before this change TeamCity could show printed bash command after some lines printed by this command.