Ansicolor not rendering ansi color codes in Jenkins output.
See original GitHub issueTest environment
- Jenkins Version: Jenkins 2.233
- AnsiColor Version: 0.6.3
- Operating System running Jenkins: amd64 Linux 4.14.173-106.229.amzn1.x86_64
Expected behavior
Jenkins pipeline calls Ansible to run a shell command with the shell module on a remote host. The shell runs an executable that returns ansi escape and color characters. Expected output is Ansicolor plugin rendering color codes in to defined colored text.
Actual behavior
When the Ansible module returns output that includes Ansi color code characters, Ansicolor-plugin is not rendering them as it should.
Steps to reproduce the behavior
Run ansible-playbook against a remote host
ANSIBLE_FORCE_COLOR=true ANSIBLE_LOAD_CALLBACK_PLUGINS=1 ANSIBLE_STDOUT_CALLBACK=default ansible-playbook shell-script.yml
The shell script should execute a command or program that produces text coloring in the output. e.g. printf, echo, …
Ansible task output displayed in Jenkins will include output that contains unrenderred ansi color characters.
Issue checklist
- Jenkins version
- AnsiColor version
- Operating System name and version
- Expected behavior
- Actual behavior
- Steps to reproduce the behavior
First step is to upgrade to version 0.7.3 to see if that fixes our current issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
I did just that. Debugged and stepped through what’s happening:
u'stdout
corresponds to the raw output that is saved in a results dictionary. The string it points to below is what will get printed to the console.It looks like theWe’re using theAnsibleUnsafeText
type when converted to a string makes sure to escape those sequences.yaml
callback plugin, when it uses yaml.dump() the escape sequence is itself escaped.I’m Looking at how I might be able to allow those escapes to bubble up within Ansible so Ansicolor can do its work. Thanks for looking through this with us.
Exactly.
The following lines
confirm that this is indeed happening:
ESC
(shown as^[
) gets properly interpreted byansicolor
but\u001b
from youryml
gets escaped somewhere along the way and ends up being printed verbatim and thus - not interpreted.