Control characters appearing in job output in 0.6.0
See original GitHub issueI’m seeing control characters show up in coloured job output where previously there were none before. It seems that this could be somewhat related to #141.
Test environment
- Jenkins Version: 2.148
- AnsiColor Version: 0.6.0
- Hostsystem: Debian stretch
Expected behavior
Up until 0.6.0 I would only occasionally see [0m characters show up and they did not affect output. The following appears when testing against 0.5.3

Actual behavior
With 0.6.0 I now see more control characters and in some cases no colour output at all:

In more complex jobs with more varied colour output, the colour output will not be properly bounded and will leak into following lines.
Steps to reproduce the behavior
The above outputs were reproduced by running the following job using the pipeline library:
def label = "terraform-${UUID.randomUUID().toString()}"
podTemplate(label: label, inheritFrom: 'jnlp', containers: [
containerTemplate(
name: 'terraform',
image: 'hashicorp/terraform',
ttyEnabled: true,
command: 'cat',
alwaysPullImage: true,
)
]) {
node(label) {
container('terraform'){
ansiColor('xterm') {
sh """
terraform plan
"""
}
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:21 (8 by maintainers)
Top Results From Across the Web
Control characters appear in data in Cognos Analytics 11 - IBM
When the database contains control character values (characters with ascii value 31 and under, or hex value 20 and under), they are displayed...
Read more >Special Characters - L3HarrisGeospatial.com
Within the IDL environment, a number of characters have special meanings. ... The dollar sign character can appear anywhere a space is legal...
Read more >Special Characters -- in a create user command - Ask TOM
I need to pass special characters into the password variable. ... Good job defining which special characters may and may not be used...
Read more >unix - print distinct list of control characters in a file
Does anyone have a function (awk, bash, perl.etc) that could scan each line and then output (in octal, hex or ascii - either...
Read more >How to replace ASCII special characters in SQL Server
Table 2 shows a sample list of the ASCII Control Characters. ... C# Console application shown in Script 4 that generates an output.txt...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It seems that Terraform attempts to format the output using color. However, Jenkins does not output this formatting correctly and thus you see those unusual characters in the output.
Thanks to this thread, I was able to make Terraform omit those characters in the output by using the
-no-colorflag.This options is available for at least three of the major Terraform functions:
show,plan, andapply. It’s probably available for others, I just haven’t confirmed it.I just released 0.6.2 with a change that should improve this issue. If you are still seeing it after the upgrade, please copy-and-paste some of the broken output from Jenkins here (preferably replacing literal occurrences of the ASCII character
0x1bwith the text0x1bso we can see what is happening to the escape sequences).