4371 shaares
I took me some time to figure it out, so I'm sharing this here:
import hudson.EnvVars
import org.jenkinsci.plugins.workflow.steps.EnvironmentExpander
def env = EnvironmentExpander.getEffectiveEnvironment(new EnvVars(), null, steps.getContext(EnvironmentExpander.class), null, null)
def ansiColorEnabled = 'TERM' in env