I know it's possible to display color in the console output using the AnsiColor plugin. I tested a basic example below:
// This shows a simple build wrapper example, using the AnsiColor plugin.
node {
// This displays colors using the 'xterm' ansi color map.
ansiColor('xterm') {
// Just some echoes to show the ANSI color.
stage "\u001B[31mI'm Red\u001B[0m Now not"
}
}
However, this example is too basic and essentially hardcoded. Is it possible to utilize AnsiColor to make the entire console output color coded? For example, when I execute Nuget and MSBuild for a .NET project, I would like the console output to color code the warnings, errors, etc.
The AnsiColor Plugin "adds support for ANSI escape sequences, including color, to Console Output" (https://wiki.jenkins.io/display/JENKINS/AnsiColor+Plugin). It merely acts as a wrapper so that the Jenkins Console Output correctly displays colors, the plugin itself does not add ANSI escape sequences nor colors to the Console Output.
A good example is with the Ansible Plugin for which "colorized output can be enabled with the argument 'colorized: true'" (https://wiki.jenkins.io/display/JENKINS/Ansible+Plugin#AnsiblePlugin-ColorizedOutput). The Ansible Plugin's colorized output requires the AnsiColor Plugin else the Jenkins Console Output is incapable of displaying the colors.
Colorized output without the AnsiColor Plugin wrapper:
stage('build'){
node('master'){
...
ansiblePlaybook colorized: true, installation: 'ansible2.5.11', inventory: 'inventory/hosts', playbook: 'playbooks/example.yml'
}
}
Colorized output with the AnsiColor Plugin wrapper:
stage('build'){
node('master'){
...
ansiColor('xterm') {
ansiblePlaybook colorized: true, installation: 'ansible2.5.11', inventory: 'inventory/hosts', playbook: 'playbooks/example.yml'
}
}
}
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