I want to display colored output in jenkins which is produced by node.js
Both work separately, but not combined:
Node Script My test script test.js:
console.log(require("chalk").red("Node Red"))
Calling the test script in the shell works:
node test.js => OK
Calling a colored shell script in jenkins works:
echo -e "\033[31mShell Red\033[0m" => OK
But calling the node script in jenkins does not display any colors:
node test.js => No Color, when executed in jenkins
The answer of Raphael pointed me in the right direction. Here my complete solution for a Jenkins Pipeline Script (Scripted Pipeline): :
If you are using the Declarative Pipeline see https://jenkins.io/doc/pipeline/tour/environment/ how to set environment variables in a Declarative Pipeline Script.