Colour in concourse web


#1

Hi,

Part of our pipeline uses Maven to build our Java SDK and run some tests on it. Maven is somehow able to colourise its output, like so;

Screenshot%20from%202018-08-03%2014-10-05

I am trying to colourise the output of another task, but I am unable to get this to work (I tried to attach a screenshot, but apparently I can only attach one image).

Here’s what I’m trying:

platform: linux
  image_resource:
    type: docker-image
    source:
      repository: alpine
  run:
    path: /bin/sh
    args: 
      - -c
      - |
        echo '\033[0;31m'"Hello, world!"'\033[0m'

And many other variants of this. Does anyone have any idea how I might get this to work?

Thanks,


#2

try using printf instead of echo:

printf "\e[31mHello, World!\e[0m\n"


#3

Hi rob, thanks for your reply.

Unfortunately, printf doesn’t work either.

EDIT: I am mistaken. I could have been sure I’d tried printf previously, but I gave that a go, and it works. Next question is why it doesn’t work in dotnet…

Regardless, echoing out colour escape codes isn’t really where I’m seeing the problem (this only reproduces it) - the actual tool that should be colourising its output is a dotnet core program (and it does colourise as intended in a terminal).

I suspect the CLR is determining the terminal type and eliding the colour output…

Thanks,


#4

Updated - it turns out I was being stupid.


#5

Ok, I seem to have it working now.

All I had to do was to add

export TERM="xterm-256color"

before I ran my tool.