How can I force Jenkins Blue Ocean to display print output instead of "Print Message"?

Solution 1:

This seems to be a known issue: https://issues.jenkins-ci.org/browse/JENKINS-53649

It looks like that BlueOcean does not handle the Groovy GStrings correctly. This is what I've observed:

A simple:

echo "hello world"

will work as expected and will display correctly. Whereas a templated string with variables, like:

echo "hello ${some_variable}"

will hide the message under a "Print Message" dropdown.

See also this answer.

Solution 2:

It appears that if echo uses a variable with value from params or environment (i.e. "params.*"), then step label gets "Print message" name instead of actual value being echoed. It does not matter if the variable itself is a String or not. Even explicitly converting the params value to String does not help.

String param_str
String text_var_2

parameters {
    string(name: 'str_param', defaultValue: 'no value')
}

                param_str = params.str_param.toString()

                echo "string text in double quotes is ${param_str}"
                echo "simple quoted string is here"
                echo 'simple quoted string is here' 
                echo 'Single quoted with str ' + param_str + ' is here'
                echo param_str                    
                text_var_2 = 'Single quoted str ' + param_str + ' combined' 
                echo "GString global text2 is ${text_var_2}" 
                echo 'String global text2 is' +  text_var_2

BlueOcean shows simple quoted strings in step label, but everything else as "Print message".

BlueOcean output

Note that 'normal' variables (strings, integers) are not included into this example, but they are also shown in the label normally. So if you have a code like this

def text_str = 'Some string'
def int_var = 1+2
echo text_str + ' is here'
echo int_var

These will be shown on the label.

And indeed it appears to be a known Jenkins issue as stated in a previous answer.