7

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.

mirekphd
  • 4,799
  • 3
  • 38
  • 59
cdeszaq
  • 30,869
  • 25
  • 117
  • 173
  • Good point, how about `play -Dsbt.log.noformat=true dist` for an instance? – biesior Mar 26 '14 at 17:32
  • @biesior that worked! Make that into an answer, and I'll gladly accept it! – cdeszaq Mar 26 '14 at 18:15
  • possible duplicate of [How can colored terminal output be disabled for simple-build-tool](http://stackoverflow.com/questions/4267014/how-can-colored-terminal-output-be-disabled-for-simple-build-tool) – Jacek Laskowski Mar 26 '14 at 19:49
  • @JacekLaskowski I saw that question, but the Play runner is different from SBT. Nothing I tried (prior to getting the answer here) worked to allow me to turn it off from the command line. This question is Play-specific, not SBT in general. – cdeszaq Mar 28 '14 at 14:55
  • Play command is sbt with the play plugin and colours come from sbt. How is the accepted answer different from the one pointed at? Please elaborate. – Jacek Laskowski Mar 28 '14 at 15:59
  • The linked question makes no direct mention of Play and how it might apply to the Play commands. I know that I burned far more time than I want to admit dealing with this (after I found the linked question), so the connection between sbt / java and Play is not particularly clear. This question also has additional context, with the specific problem I was trying to solve (the output in Jenkins logs). Finally, I'm developing Play with Java, so the scala-side of things is more "black magic" than I'm used to, hence this question. – cdeszaq Mar 28 '14 at 16:20
  • Point taken! I was missing the part that makes no connection between sbt and play that can't be obvious for newcomers. Thanks for patience. I'm sold to keep the question (rather than closing it as a duplicate). – Jacek Laskowski Mar 28 '14 at 17:21

2 Answers2

4

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

Slav
  • 27,057
  • 11
  • 80
  • 104
  • Great, does it work also with existing logs (from previous builds?) – biesior Mar 27 '14 at 16:02
  • 2
    You mean "current running build" vs "existing builds"? Yes it does. If you are asking "before plugin was installed" vs "after plugin was installed"... don't know, but I don't see why not. It does not inject anything new into the log, it just affects how the log is displayed – Slav Mar 27 '14 at 16:31
  • I meant second option, however will check it soon myself ;) – biesior Mar 27 '14 at 18:46
  • Unfortunately, I don't have the ability to add plugins to Jenkins, and the likelihood of getting it approved is... minimal at best. – cdeszaq Mar 28 '14 at 14:54
  • @cdeszaq yay, we can tell Jenkins to wipe off the whole filesystem and cause a nuclear holocaust, but we can't install a new plugin... I am not in your situation with Jenkins, but i've definitely hit this brick wall many times in other areas... I feel for you. – Slav Mar 28 '14 at 15:01
3

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"
biesior
  • 55,576
  • 10
  • 125
  • 182
  • 1
    or there is always [Ansi-Color plugin](https://wiki.jenkins-ci.org/display/JENKINS/AnsiColor+Plugin) – Slav Mar 27 '14 at 15:49