jenkins ansiColor not working with unexpected characters

170 Views Asked by At

Jenkins 2.405

ansiColor plugin installed (jenkins restarted after installation)

enter image description here

in the pipeline (scripted), I have following snippet to call ansiColor

ansiColor('xterm') {
    echo -e '\033[31mERROR:\e[0m xxxx'
}

Then I got this exception:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 33: unexpected char: '\' @ line 33, column 48.
          echo -e '\033[31mERROR:\e[0m xxxx
                                 ^

1 error

how could I make this solved?

1

There are 1 best solutions below

0
Solaris_9 On

it's weird, if I change the snippet to blow, it works

ansiColor('xterm') {
    echo '\033[31mERROR:\033[0m xxxx'
}

there are two things unclear:

  1. why \e isn't working, does it has special meaning in groovy?
  2. why -e option couldn't be used?