19

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.

Caesar Kabalan
  • 753
  • 1
  • 8
  • 18
  • I've noticed this too. It's not very useful. Short answer is, I don't think you can. Having implemented a plugin recently, I realised it is the display name for the pipeline step provided by the plugin that implements it. From here look for the getDisplayName() method: https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/steps/EchoStep.java – macg33zr Mar 29 '18 at 21:39
  • Having the same issue and can't understand how 5 different lines print out with and without "Print Message" using echo. – Marcello DeSales Oct 02 '18 at 06:03
  • Got into this same problem today... I noticed that if you call a step embedded into another shared library, all the statements print link that... Still investigating... – Marcello DeSales Apr 26 '19 at 19:59
  • I'm here again... No signs of identifying the reasons why this happens... – Marcello DeSales May 06 '19 at 17:52

5 Answers5

7

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.

Hüda
  • 399
  • 3
  • 5
6

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.

Roman Komarov
  • 61
  • 1
  • 3
5

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)
tlvince
  • 516
  • 3
  • 10
1

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

Nauzet
  • 661
  • 8
  • 20
0

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);
      }