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

User is trapped if a parallel stage is skipped. Blueocean shows "Waiting for run to start" instead of log messages.

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • blueocean-plugin
    • None
    • Jenkins 2.89.2
      BlueOcean 1.3.5
    • Blue Ocean 1.6 - beta 2, Blue Ocean - 1.6 - beta 4

      In a pipeline with two parallel stages where one stage is skipped BlueOcean shows "Waiting for run to start", although the other stage produces log outputs. (See Waiting.PNG)

      It seems like the skipped stage is selected by default. However, there is no output.

      If there is an additional stage after the parallel stages and the pipeline reaches this stage, the pipeline is visualized properly. However, if you click on the skipped stage the message "Waiting for a run to start" is shown again. 

      Steps to reproduce:

      Execute the following pipeline:

      pipeline {
          agent any
          options {
              timeout(time: 120, unit: 'MINUTES')
              timestamps()
              skipDefaultCheckout()
          }
          stages {
              stage('Parallel Stage') {
                  parallel {
                      stage("Executed Stage") { 
                          steps { 
                              script {
                                for(i=0; i<1000;i++){
                                  echo "Temp"
                                  sleep 1
                                } 
                              } 
                          } 
                      }
                      stage("Skipped Stage") {
                          when { expression { false } }
                          steps { 
                              echo "I am skipped"    
                          }
                      }
                  }
              }
          }
      }
      
      

          [JENKINS-48879] User is trapped if a parallel stage is skipped. Blueocean shows "Waiting for run to start" instead of log messages.

          Ivan Meredith added a comment -

          coervivek There is an issue in the rest api. While the stages are executing PIpelineStepVisitor.currentStage is always set to be a stage that is skipped for conditional. therefore it does not add any steps. But if you cancel the job, this is no longer the case. I'm stuck on this, I don't know enough about how this works.

          Ivan Meredith added a comment - coervivek There is an issue in the rest api. While the stages are executing PIpelineStepVisitor.currentStage is always set to be a stage that is skipped for conditional. therefore it does not add any steps. But if you cancel the job, this is no longer the case. I'm stuck on this, I don't know enough about how this works.

          Ivan Meredith added a comment -

          svanoort Not sure if you can help here, I noticed your name on StandardChunkVisitor  

           

          Its always skipped at https://github.com/jenkinsci/blueocean-plugin/blob/master/blueocean-pipeline-api-impl/src/main/java/io/jenkins/blueocean/rest/impl/pipeline/PipelineStepVisitor.java#L159 , the debugger never hits the next line

          Ivan Meredith added a comment - svanoort Not sure if you can help here, I noticed your name on StandardChunkVisitor     Its always skipped at https://github.com/jenkinsci/blueocean-plugin/blob/master/blueocean-pipeline-api-impl/src/main/java/io/jenkins/blueocean/rest/impl/pipeline/PipelineStepVisitor.java#L159  , the debugger never hits the next line

          I have the same problem here.

          William Laszlo added a comment - I have the same problem here.

          Dawn Minion added a comment -

          Still present in Blue Ocean 1.9.0. Really annoying being unable to see how our parallel stages are doing when one is skipped, have to resort to sifting through the classic console logs. 

           

          Dawn Minion added a comment - Still present in Blue Ocean 1.9.0. Really annoying being unable to see how our parallel stages are doing when one is skipped, have to resort to sifting through the classic console logs.   

          Blue Ocean 1.13. The issue still present

          Alex Simenduev added a comment - Blue Ocean 1.13. The issue still present

          Daniel Russel added a comment -

          A hack that works for us is to add an always active stage that is alphabetically last. That doesn't seem consistent with William Laszlo's post though.

          Daniel Russel added a comment - A hack that works for us is to add an always active stage that is alphabetically last. That doesn't seem consistent with William Laszlo's post though.

          Still reproducible with Jenkins 2.222.1 and Blue Ocean 1.22.0

          Artur Czarnota added a comment - Still reproducible with Jenkins 2.222.1 and Blue Ocean 1.22.0

          DP added a comment - - edited

          This issue is still reproducible with Jenkins 2.275 and Blue Ocean 1.24.3.

          Based on drussel's comment, I found that the "Waiting for run to start" message will be shown only until the stage defined at the bottom of a parallel block finishes.

          As a workaround, add a new dummy stage at the end of a parallel block, which finishes its steps quickly.

          For example, with the following pipeline script, the logs of stage "b" will appear as soon as the stage "Workaround" finishes.

          pipeline {
              agent any
              stages {
                  stage('parent') {
                      parallel {
                          stage('a') {
                              when { expression { false } }
                              steps {
                                  sleep 30
                              }
                          }
                          stage('b') {
                              when { expression { true } }
                              steps {
                                  sleep 20
                              }
                          }
                          stage('c') {
                              when { expression { false } }
                              steps {
                                  sleep 15
                              }
                          }
                          stage('(Workaround)') {
                              steps {
                                  sleep 10
                              }
                          }
                      }
                  }
              }
          }
          

          Modifying the "Workaround" stage to just echo a message will allow the logs of the other stages to be viewed almost instantaneously.

          I also found that the name of this extra stage does not matter - it doesn't have to be alphabetically last. But the extra stage must be defined as the last stage in the parallel block.

          DP added a comment - - edited This issue is still reproducible with Jenkins 2.275 and Blue Ocean 1.24.3. Based on drussel 's comment, I found that the "Waiting for run to start" message will be shown only until the stage defined at the bottom of a parallel block finishes. As a workaround, add a new dummy stage at the end of a parallel block, which finishes its steps quickly. For example, with the following pipeline script, the logs of stage " b " will appear as soon as the stage " Workaround " finishes. pipeline { agent any stages { stage( 'parent' ) { parallel { stage( 'a' ) { when { expression { false } } steps { sleep 30 } } stage( 'b' ) { when { expression { true } } steps { sleep 20 } } stage( 'c' ) { when { expression { false } } steps { sleep 15 } } stage( '(Workaround)' ) { steps { sleep 10 } } } } } } Modifying the " Workaround " stage to just echo a message will allow the logs of the other stages to be viewed almost instantaneously. I also found that the name of this extra stage does not matter - it doesn't have to be alphabetically last. But the extra stage must be defined as the last stage in the parallel block.

          Patrick added a comment - - edited

          drussel, zhaxmdi0 both of you, deserve a prize. Thank you so much for bringing up this workaround.

          My team has also been affected by this particular bug. Even worse we were using input() inside our stage definitions and Blue Ocean wouldn't render the user input dialog. Instead we'd have to switch back to classic view and since there might be multiple stages in parallel waiting for user approval, it's rather hard to correlate the input box with the corresponding stage in classic view.

          It has taken us two full days to find a solution for this problem, none of which succeeded until we've found your suggestion. Works like a charm.

          For reference: We're using Jenkins 2.207 with Blue Ocean 1.21.0

          Kind regards from myself and my team,

          Patrick

          Patrick added a comment - - edited drussel , zhaxmdi0  both of you, deserve a prize. Thank you so much for bringing up this workaround. My team has also been affected by this particular bug. Even worse we were using input() inside our stage definitions and Blue Ocean wouldn't render the user input dialog. Instead we'd have to switch back to classic view and since there might be multiple stages in parallel waiting for user approval, it's rather hard to correlate the input box with the corresponding stage in classic view. It has taken us two full days to find a solution for this problem, none of which succeeded until we've found your suggestion. Works like a charm. For reference: We're using Jenkins 2.207 with Blue Ocean 1.21.0 Kind regards from myself and my team, Patrick

          Andy added a comment -

          I just ran into this and posted on SO about. Was going to post a bug here but found this one. Appears to be the same issue. Adding a dummy workaround stage as suggested by zhaxmdi0 appears to help. I'll answer my SO post with a link to this ticket - https://stackoverflow.com/questions/77029029/queued-waiting-for-run-to-start-with-conditional-parallel-stages

          Andy added a comment - I just ran into this and posted on SO about. Was going to post a bug here but found this one. Appears to be the same issue. Adding a dummy workaround stage as suggested by zhaxmdi0 appears to help. I'll answer my SO post with a link to this ticket - https://stackoverflow.com/questions/77029029/queued-waiting-for-run-to-start-with-conditional-parallel-stages

            Unassigned Unassigned
            kurzy Daniel Kurzynski
            Votes:
            33 Vote for this issue
            Watchers:
            34 Start watching this issue

              Created:
              Updated: