How to use the ANSIcolor plugin in Jenkins?

The ANSI-color plug in transforms your console output to HTML. If your output contains ansi escape sequences, then it converts these special char sequences into (colored) HTML. You can only configure the mapping via 'ANSI color map'.

Example:
\x1b[31m is transformes html color red

It looks that your program does't use Escape sequences. But if you wrote your own software or script, you can use these Escape sequences.

1st Example BASH:

echo -e "\033[31mRed\033[0m"

2nd Example BASH:

printf "\033[31mRed\033[0m"

If you need it, you have to add a newline sequence to printf:

printf "\033[31mRed\033[0m\n"

More to Escape sequences:
English: http://en.wikipedia.org/wiki/ANSI_escape_code
Deutsch: http://de.wikipedia.org/wiki/Escape-Sequenz


There's a lot more documentation available on the Jenkins-ANSIcolor plugin here: https://github.com/dblock/jenkins-ansicolor-plugin

I wasn't seeing colors because I was using "high intensity" colors (in the 90's range) and these aren't supported. Gotta stick to colors in the 30's


  1. Double check that the software really is outputting ANSI colours. For example, a bash script running this echo will produce colour with the AnsiColor plugin installed, but it'll produce messed-up escape sequences in the console output with no plugin.

In BASH:

echo -e '\033[35mPurple!\033[0m'
  1. Check your project configuration, check the "Build Environment" and make sure "Color ANSI Console Output" is checked.

  2. If you can't find the "Build Environment" section, go to Manage Plugins to double-check that the right plugin is really installed.
    (I recently installed the "Ansible" plugin instead of "AnsiColor"....)


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.

Set-by-step guide

  1. Install AnsiColor plugin Under Build Environment section check Color ANSI Console OutputJenkins -
  2. Color ANSI Console Output -should look like

  3. TesterFenster Inside Execute shell step add something like:

set +x


info() {

echo "\033[1;33m[Info]    \033[0m $1"

}

error() {

echo "\033[1;31m[Error]   \033[0m $1"

}

success() {

echo "\033[1;32m[Success] \033[0m $1"

}



info "This is information message"

error "Houston we have a problem"

success "Great!!!"


echo "Foreground colors"

echo "\033[31m Red \033[0m"

echo "\033[32m Green \033[0m"

echo "\033[33m Yellow \033[0m"

echo "\033[34m Blue \033[0m"
siz
echo "\033[35m Magneta \033[0m"

echo "\033[36m Cyan \033[0m"


echo "Background colors"

echo "\033[41m Red \033[0m"

echo "\033[42m Green \033[0m"

echo "\033[43m Yellow \033[0m"

echo "\033[44m Blue \033[0m"

echo "\033[45m Magneta \033[0m"

echo "\033[46m Cyan \033[0m"


echo "Different combinations"

echo "\033[1;31m Red \033[0m"

echo "\033[1;4;37;42m Green \033[0m"

echo "\033[1;43m Yellow \033[0m"


set -x
you should see like your output

This only works from the Jenkins console, and not from the actual scripts that out put to your console Output