How can I turn off color codes when running Play commands?

心不动则不痛 提交于 2019-12-07 03:45:17

问题


When I run Play commands, the logs come out nicely colored and clean in the terminal, but when I build my application in Jenkins, the logs there show the color codes, rending them amazingly hard to read.

Command-line logs:

[info] ApplicationSpec
[info] Application should
[info] + send 404 on a bad request
[info] x render the index page
[error]    '401' is not equal to '200' (ApplicationSpec.scala:25)
[info] Total for specification ApplicationSpec
[info] Finished in 134 ms
[info] 2 examples, 1 failure, 0 error
[error] Failed: Total 3, Failed 2, Errors 0, Passed 1
[error] Failed tests:
[error]     ApplicationSpec
[error]     IntegrationSpec
[error] (test:test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 23 s, completed Mar 26, 2014 10:00:34 AM

Jenkins logs:

[0m[[0minfo[0m] [0mApplicationSpec[0m
[0m[[0minfo[0m] [0mApplication should[0m
[0m[[0minfo[0m] [0m[32m+[0m send 404 on a bad request[0m
[0m[[0minfo[0m] [0m[33mx[0m render the index page[0m
[0m[[31merror[0m] [0m   '401' is not equal to '200' (ApplicationSpec.scala:25)[0m
[0m[[0minfo[0m] [0mTotal for specification ApplicationSpec[0m
[0m[[0minfo[0m] [0m[34mFinished in 229 ms[0m[0m
[0m[[0minfo[0m] [0m[34m2 examples, 1 failure, 0 error[0m[0m
[0m[[31merror[0m] [0mFailed: Total 3, Failed 2, Errors 0, Passed 1[0m
[0m[[31merror[0m] [0mFailed tests:[0m
[0m[[31merror[0m] [0m   ApplicationSpec[0m
[0m[[31merror[0m] [0m   IntegrationSpec[0m
[0m[[31merror[0m] [0m(test:[31mtest[0m) sbt.TestsFailedException: Tests unsuccessful[0m
[0m[[31merror[0m] [0mTotal time: 6 s, completed Mar 25, 2014 2:28:01 PM[0m

As you can see, the Jenkins output still has the same content, but the color codes make it so noisy that it's really hard to figure out what's going on.

I've found limited information on how to turn color codes off for the SBT tool, but I can't figure out how to pass this in through the play commands when running my builds through Jenkins.


回答1:


De facto I was curious also (have the same problem) so checked suggestion you sent :)

Answer is:

play -Dsbt.log.noformat=true dist

Or (if more params should be sent to console like non-default port no.) as usually:

play -Dsbt.log.noformat=true "~run 9123"



回答2:


Or you can install Ansi-Color Jenkins plugin, and actually have the colors in your Jenkins's log



来源:https://stackoverflow.com/questions/22665543/how-can-i-turn-off-color-codes-when-running-play-commands

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!