Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-53649

Strings from the "echo" step are suppressed in BlueOcean UI if they contain values found in an environment variable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • workflow-cps-plugin
    • Jenkins: 2.138.1
      BlueOcean plugin: 1.8.2
      A clean install on Windows 7 with just a standard set of plugins
      Reproed with Chrome on Windows and Firefox on a Linux desktop

      When a string is displayed in the BlueOcean UI from an "echo" step, the string "Print Message" is displayed IF the string being echoed contains a substring that matches the contents of any environment variable. 

      Repro steps:

      Create a pipeline with this code:

      pipeline {
          agent any
          stages {
              stage('test') {
                  environment {
                      THING = 'foobarbuzz'
                  }
                  steps {
                      echo "blah"
                      echo "foobarbuzz"
                      echo "foobarZZZbuzz"
                      echo "This is a $THING here"
                  }
              }
          }
      }

      Run the pipeline via Blue Ocean

      Observe that there are four step labels displayed in the Blue Ocean UI. (see attached screenshot)  The first and third steps display the strings from "echo" as expected.  But, the second and fourth steps display only "Print Message" and don't show the expected string.  The user needs to click the step to expand it to see the string.  I would expect that all strings from all echo statements should show up in the main Blue Ocean UI and would not require some to be manually expended.

       

          [JENKINS-53649] Strings from the "echo" step are suppressed in BlueOcean UI if they contain values found in an environment variable

          S Nelson created issue -
          S Nelson made changes -
          Attachment New: EchoNotShowingSomeStrings.PNG [ 44522 ]
          Description Original: When a string is displayed in the BlueOcean UI from an "echo" step, the string "Print Message" is displayed IF the string being echoed contains a substring that matches the contents of any environment variable. 

          Repro steps:

          Create a pipeline with this code:
          {noformat}
          pipeline {
              agent any
              stages {
                  stage('test') {
                      environment {
                          THING = 'foobarbuzz'
                      }
                      steps {
                          echo "blah"
                          echo "foobarbuzz"
                          echo "foobarZZZbuzz"
                          echo "This is a $THING here"
                      }
                  }
              }
          }{noformat}
          Run the pipeline via BlueOcean

          Observe that there are four step labels displayed in the BlueOcean UI.  The first and third steps display the strings as expected.  But, the second and fourth steps display only "Print Message" and don't show the expected string.  The user needs to click the step to expand it to see the string.

           
          New: When a string is displayed in the BlueOcean UI from an "echo" step, the string "Print Message" is displayed IF the string being echoed contains a substring that matches the contents of any environment variable. 

          Repro steps:

          Create a pipeline with this code:
          {noformat}
          pipeline {
              agent any
              stages {
                  stage('test') {
                      environment {
                          THING = 'foobarbuzz'
                      }
                      steps {
                          echo "blah"
                          echo "foobarbuzz"
                          echo "foobarZZZbuzz"
                          echo "This is a $THING here"
                      }
                  }
              }
          }{noformat}
          Run the pipeline via Blue Ocean

          Observe that there are four step labels displayed in the Blue Ocean UI. (see attached screenshot)  The first and third steps display the strings from "echo" as expected.  But, the second and fourth steps display only "Print Message" and don't show the expected string.  The user needs to click the step to expand it to see the string.  I would expect that all strings from all echo statements should show up in the main Blue Ocean UI and would not require some to be manually expended.

           
          Summary Original: Strings from the "echo" step are suppressed in BlueOcean UI if they contain values found in ENVIRONMENT New: Strings from the "echo" step are suppressed in BlueOcean UI if they contain values found in an environment variable

          This does not happen for me for the step echo "Executing On: $env.NODE_NAME" but I do observe it using echo "branch sync @ $scmVars.P4_CHANGELIST" (scmVars returned from the p4sync step) and echo "$tp_mkspec sync @ $env.P4_CHANGELIST" (tp_mkspec is a groovy var)

          Alisdair Robertson added a comment - This does not happen for me for the step echo "Executing On: $env.NODE_NAME" but I do observe it using echo "branch sync @ $scmVars.P4_CHANGELIST" (scmVars returned from the p4sync step) and echo "$tp_mkspec sync @ $env.P4_CHANGELIST" (tp_mkspec is a groovy var)

          I've created a step and implemented the String argumentsToString(Map<String, Object> namedArgs) method and it works most of the time, but it seems that if the argument has and env value in it the argument passed is empty. Is there a way to disable this behaviour or override it?

          Hilario Fernandes added a comment - I've created a step and implemented the  String argumentsToString(Map<String, Object> namedArgs) method and it works most of the time, but it seems that if the argument has and env value in it the argument passed is empty. Is there a way to disable this behaviour or override it?

          Marcello de Sales added a comment - - edited

          Works with Strings = Displays Correctly

          I'm on the same boat... I observed the following:

          • Strings work as expected
          echo "Running Sonar Scan with reports at ${context.reports.sonarqube.server}"
          • If the Strings are separate, they just work (notice the space between the variable and the String "/dashboard/index/"

           

          echo "Running Sonar Scan with reports at ${context.reports.sonarqube.server} /dashboard/index/"

           

          Doesn't work with GStringImpl = Print Message

          • But concatenating Strings with variables, it will result in a GStringImpl, which won't work

           

          echo "Running Sonar Scan with reports at ${context.reports.sonarqube.server}"
          def url = "${context.reports.sonarqube.server}/dashboard/index/${context.library.groupId}:${context.library.artifactId}"
          echo "URL is ${url}"
          • If I concat the String on the same URL above it won't work either

           

          echo "Running Sonar Scan with reports at ${context.reports.sonarqube.server}/dashboard/index/"

          Marcello de Sales added a comment - - edited Works with Strings = Displays Correctly I'm on the same boat... I observed the following: Strings work as expected echo "Running Sonar Scan with reports at ${context.reports.sonarqube.server}" If the Strings are separate, they just work (notice the space between the variable and the String "/dashboard/index/"   echo "Running Sonar Scan with reports at ${context.reports.sonarqube.server} /dashboard/index/"   Doesn't work with GStringImpl = Print Message But concatenating Strings with variables, it will result in a GStringImpl, which won't work   echo "Running Sonar Scan with reports at ${context.reports.sonarqube.server}" def url = "${context.reports.sonarqube.server}/dashboard/index/${context.library.groupId}:${context.library.artifactId}" echo "URL is ${url}" If I concat the String on the same URL above it won't work either   echo "Running Sonar Scan with reports at ${context.reports.sonarqube.server}/dashboard/index/"

          marcellodesales i do not think this is related to GStrings. I've tested with pure hardcoded strings and if any part of the string matches a value of an enviroment variable the string is not shown.

          Hilario Fernandes added a comment - marcellodesales i do not think this is related to GStrings. I've tested with pure hardcoded strings and if any part of the string matches a value of an enviroment variable the string is not shown.

          Ian Katz added a comment -

          I also question this String/GStringImpl correlation.  You can reproduce this issue by echoing a static string multiple times, as shown in the original attachment for this issue.  In my own case, echoing the exact same static string multiple times produced inconsistent results.

          Ian Katz added a comment - I also question this String/GStringImpl correlation.  You can reproduce this issue by echoing a static string multiple times, as shown in the original attachment for this issue.  In my own case, echoing the exact same static string multiple times produced inconsistent results.
          Roman Komarov made changes -
          Attachment New: print_message_param_string.png [ 47494 ]
          Roman Komarov made changes -
          Attachment New: print_message_param_string.png [ 47495 ]

          Roman Komarov added a comment -

          Same happens if echo uses a variable from parameters (i.e. anything from params.*). Does not matter if the variable 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
          
          

           

           

          The output is as this:

          Anything that contains the variable from param is "Print Message".

          If a variable is a simple string or a calculated integer - it is shown in the step label normally. 

          Roman Komarov added a comment - Same happens if echo uses a variable from parameters (i.e. anything from params.*). Does not matter if the variable 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     The output is as this: Anything that contains the variable from param is "Print Message". If a variable is a simple string or a calculated integer - it is shown in the step label normally. 

            Unassigned Unassigned
            sirgnip S Nelson
            Votes:
            25 Vote for this issue
            Watchers:
            29 Start watching this issue

              Created:
              Updated:
              Resolved: