Short:
How can I get colors for MSBuild running from Jenkins.
Long:
I have a nice Python build script that uses the pyColors module to print pretty output to console. When I'm running the script from CMD, I get colors from my script and colors from MSBuild (Ex: Blue color for "Done Building Project", Green for "Build succeeded", Red for errors).
I also run the same script from Jenkins (on Windows, of course). At the begging I got no colors in the Jenkins log (Console output). I then, installed the ANSIColor plugin, and now I only get the colors generated by the Python script, but no colors from MSBuild.
I tried to investigate it from the MSBuild project on GitHub, and I found that MSBuild has some safety try/ctach check on setting colors, that is probably failing (BaseConsoleLogger.cs line 455). I think that the Python module is simply printing raw ANSI escape characters, while the Win32 API for setting colors is failing when the console output is redirected.
P.S.
I'm using fully updated Jenkins on Windows 8 with Visual Studio 2015 SP1
Install AnsiColor plugin On Jenkins: Manage Jenkins > Manage Plugins > Available > search and install 'Ansi Color' 2. Configure your build/job Under Build Environment section check Color ANSI Console Output and select xterm 3. Inside Execute shell step add something like:
Jenkins console output is place where you can spend decent amount of time trying to figure out what went wrong (or perhaps right?). AnsiColor plugins gives you opportunity to color monochromatic Jenkins console output. 1. Install AnsiColor plugin On Jenkins: Manage Jenkins > Manage Plugins > Available > search and install 'Ansi Color'
Let's log in into Jenkins as shown in the below screen. It will show a list of items shown as per the below screen, from that list select Global Tool Configuration. From the Global tool configurations, you can setup MSBuild Configuration.
As @ocodo wrote, cmd.exe (which is triggered by Jenkins) is not a terminal emulator, so it won't support ANSI output from batch commands by default. So this is just unsupported on Windows.
Big success, my pull request is now merged into the MSBuild project. https://github.com/Microsoft/msbuild/commit/58350c52d6e397fe90a7a48bcf46d4dda8023510 What I was looking for will be possible with the next release of Visual Studio using /forceConsoleColor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With