How to remove colors from Maven output?

When I run the maven target in Jenkins (for example, "mvn test"), the logs are very difficult to read due to the displayed color control characters (see example below). Is there a way to remove color formatting?

[[1;34mINFO[m] [1m-------------------------------------------------------------------[m [[1;34mINFO[m] [1;32mBUILD SUCCESS[m [[1;34mINFO[m] [1m-------------------------------------------------------------------[m [[1;34mINFO[m] Total time: 16.097 s [[1;34mINFO[m] Finished at: 2017-04-26T11:23:06-04:00 [[1;34mINFO[m] Final Memory: 41M/100M [[1;34mINFO[m] [1m-------------------------------------------------------------------[m 
+16
source share
3 answers

Thanks to khmarbaise for his answer in the comment to my question:

you can simply define -B for -batch-mode, which will disable the use of color ..

This fixed the problem, my result now looks like this (much nicer):

 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 17.507 s [INFO] Finished at: 2017-04-27T05:30:07-04:00 [INFO] Final Memory: 41M/100M [INFO] ------------------------------------------------------------------------ 
+26
source

maven --batch-mode will do. However, if you need to check any already generated output containing these color codes, you can use sed to remove the codes, as explained here .

0
source

--batch-mode , mentioned in other answers, is indeed the best option in some circumstances, for example, on a CI server, but if you want to just turn off the color, perhaps starting with maven 3.5.1, use the following option:

 mvn -Dstyle.color=never 

Other options for the parameter: always or auto .

0
source

Source: https://habr.com/ru/post/1267194/


All Articles