Caesar Kabalan
Caesar Kabalan

Reputation: 791

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

In the below screenshot some debug entries display the output text (with - Print Message at the end) while others simply display Print Message. To view these you have to expand the step to see the output.

Jenkins Blue Ocean Output

All lines are using the format print "TEXT HERE". I've tried using print, println, and echo. All have the same output.

Why do these sometimes display the message, while others force it into a collapsed section? Is it possible to configure this to always show? The normal non-Blue Ocean Jenkins interface displays fine but there is a lot of verbosity.

Upvotes: 19

Views: 9631

Answers (5)

J. Fenech
J. Fenech

Reputation: 1

Another workaround would be to split the multiline string into an array and iterate over it :-

 String[] splitData = MULTI_LINE_STRING.split("\n");
     for (String eachSplit : splitData) {
         print(eachSplit);
      }

Upvotes: 0

tlvince
tlvince

Reputation: 516

This is a known BlueOcean bug. The console output in the "classic" view interpolates variables correctly.

One workaround is to use the label parameter of the sh step:

def message = 'Hello World'
sh(script: "echo $message", label: message)

Upvotes: 5

Roman Komarov
Roman Komarov

Reputation: 61

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.

Upvotes: 6

Hüda
Hüda

Reputation: 420

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.

Upvotes: 7

Fizban
Fizban

Reputation: 661

I tried lots of things and seems the moment an environment variable is going to be displayed, it uses Print Message instead the text.

Upvotes: 1

Related Questions