Reputation: 91
I have a Jenkins scripted pipeline which is making a salt call and running a bash script. The Script has some colour code as outlined below. I have the ANSI Color enabled. However, the colour are not getting resolved. Instead they are getting printed as is but in blue colour as ANSI color i have set "Default Foreground" to Blue. I tried with Jenkins Default color as well but no luck.
?[31;43m***** HOSTNAME INFORMATION *****?[0m
?[31;43m***** FILE SYSTEM DISK SPACE USAGE *****?[0m
?[31;43m***** TOP 5 MEMORY-CONSUMING PROCESSES *****?[0m
Upvotes: 1
Views: 1917
Reputation: 5054
Your escape sequences are wrong. Additionally, the -e flag does not work on MacOs (If you are working in MacOs).
#!/bin/bash
content='\e[31;43m***** HOSTNAME INFORMATION *****\e[0m
\e[31;43m***** FILE SYSTEM DISK SPACE USAGE *****\e[0m
\e[31;43m***** TOP 5 MEMORY-CONSUMING PROCESSES *****\e[0m\n
'
echo -e "$content" ## Does not work on MacOs
printf "$content" ## But you can use printf and add a \n at the end of string.
Upvotes: 1