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

Wrong order of steps in 'script' block of 'post' block in Blue Ocean

    Details

    • Similar Issues:
    • Sprint:
      Blue Ocean 1.5 - beta 3

      Description

      Problem
      Steps will appear out of order from where they were defined in the Jenkinsfile.

      Jenkinsfile

      pipeline {
        agent any
       
        stages {
          stage ('init') {
            steps {
              echo 'Hello World'
            }
          }
        }
      
        post {
          always {
            script {
              echo 'echo step before emailext step'
              emailext(subject: 'Test email', to: 'invalid@invalid.com')
            }
          }
        }
      }
      

      Screenshot

      Original Request
      Here the correct classic UI console log:

      Here the Blue Ocean UI with different output:

      And this is the end of the declarative pipeline code:

        post {
          failure {
            script {
              ...
            }
          }
          always {
            script {
              ...
              if (...) {
                echo 'Keeping this build forever and sending specific email notification with build report...'
                ...        
                emailext(subject: '... Recovery Build Report', to: toEmails, attachLog: true, body: htmlBody, mimeType: Constants.CONTENT_TYPE_TEXT_HTML)
              } else {
                ...
              }
            ...
      

        Attachments

          Issue Links

            Activity

            reinholdfuereder Reinhold Füreder created issue -
            Hide
            jamesdumay James Dumay added a comment -

            Hi Reinhold Füreder,

            To help us debug this issue could you please provide us with a small Jenkinsfile that reproduces the issue? That should make it clear to us what the problem is.

            Thanks
            James

            Show
            jamesdumay James Dumay added a comment - Hi Reinhold Füreder , To help us debug this issue could you please provide us with a small Jenkinsfile that reproduces the issue? That should make it clear to us what the problem is. Thanks James
            jamesdumay James Dumay made changes -
            Field Original Value New Value
            Sprint Blue Ocean 1.4 - beta 1 [ 401 ]
            Assignee James Dumay [ jamesdumay ]
            reinholdfuereder Reinhold Füreder made changes -
            Attachment image-2017-10-05-13-37-18-580.png [ 39946 ]
            reinholdfuereder Reinhold Füreder made changes -
            Attachment image-2017-10-05-13-38-27-385.png [ 39947 ]
            Hide
            reinholdfuereder Reinhold Füreder added a comment -

            In contrast to other issues, this time the re-producer is really as outlined below:

            #!/usr/bin/env groovy
            
            pipeline {
              agent any
             
              stages {
                stage ('init') {
                  steps {
                    echo 'Hello World'
                  }
                }
              }
            
              post {
                always {
                  script {
                    echo 'echo step before emailext step'
                    emailext(subject: 'Test email', to: 'invalid@invalid.com')
                  }
                }
              }
            }
            

            This leads to correct classic UI output:

            But bad Blue Ocean output:

            Show
            reinholdfuereder Reinhold Füreder added a comment - In contrast to other issues, this time the re-producer is really as outlined below: #!/usr/bin/env groovy pipeline {   agent any     stages {     stage ( 'init' ) {       steps {         echo 'Hello World'       }     }   }   post {     always {       script {         echo 'echo step before emailext step'         emailext(subject: 'Test email' , to: 'invalid@invalid.com' )       }     }   } } This leads to correct classic UI output: But bad Blue Ocean output:
            jamesdumay James Dumay made changes -
            Description Here the correct classic UI console log:
             !image-2017-10-03-08-12-06-625.png|thumbnail!

            Here the Blue Ocean UI with different output:
             !image-2017-10-03-08-13-28-073.png|thumbnail!

            And this is the end of the declarative pipeline code:
            {code:java}
              post {
                failure {
                  script {
                    ...
                  }
                }
                always {
                  script {
                    ...
                    if (...) {
                      echo 'Keeping this build forever and sending specific email notification with build report...'
                      ...
                      emailext(subject: '... Recovery Build Report', to: toEmails, attachLog: true, body: htmlBody, mimeType: Constants.CONTENT_TYPE_TEXT_HTML)
                    } else {
                      ...
                    }
                  ...
            {code}
            *Jenkinsfile*
            {code}
            pipeline {
              agent any
             
              stages {
                stage ('init') {
                  steps {
                    echo 'Hello World'
                  }
                }
              }

              post {
                always {
                  script {
                    echo 'echo step before emailext step'
                    emailext(subject: 'Test email', to: 'invalid@invalid.com')
                  }
                }
              }
            }
            {code}

            *Original Request*
            Here the correct classic UI console log:
             !image-2017-10-03-08-12-06-625.png|thumbnail!

            Here the Blue Ocean UI with different output:
             !image-2017-10-03-08-13-28-073.png|thumbnail!

            And this is the end of the declarative pipeline code:
            {code:java}
              post {
                failure {
                  script {
                    ...
                  }
                }
                always {
                  script {
                    ...
                    if (...) {
                      echo 'Keeping this build forever and sending specific email notification with build report...'
                      ...
                      emailext(subject: '... Recovery Build Report', to: toEmails, attachLog: true, body: htmlBody, mimeType: Constants.CONTENT_TYPE_TEXT_HTML)
                    } else {
                      ...
                    }
                  ...
            {code}
            jamesdumay James Dumay made changes -
            Sprint Blue Ocean 1.4 - beta 1 [ 401 ] Blue Ocean 1.4 - beta 2 [ 416 ]
            Assignee James Dumay [ jamesdumay ]
            jamesdumay James Dumay made changes -
            Description *Jenkinsfile*
            {code}
            pipeline {
              agent any
             
              stages {
                stage ('init') {
                  steps {
                    echo 'Hello World'
                  }
                }
              }

              post {
                always {
                  script {
                    echo 'echo step before emailext step'
                    emailext(subject: 'Test email', to: 'invalid@invalid.com')
                  }
                }
              }
            }
            {code}

            *Original Request*
            Here the correct classic UI console log:
             !image-2017-10-03-08-12-06-625.png|thumbnail!

            Here the Blue Ocean UI with different output:
             !image-2017-10-03-08-13-28-073.png|thumbnail!

            And this is the end of the declarative pipeline code:
            {code:java}
              post {
                failure {
                  script {
                    ...
                  }
                }
                always {
                  script {
                    ...
                    if (...) {
                      echo 'Keeping this build forever and sending specific email notification with build report...'
                      ...
                      emailext(subject: '... Recovery Build Report', to: toEmails, attachLog: true, body: htmlBody, mimeType: Constants.CONTENT_TYPE_TEXT_HTML)
                    } else {
                      ...
                    }
                  ...
            {code}
            *Problem*
            Steps will appear out of order from where they were defined in the Jenkinsfile.

            *Jenkinsfile*
            {code}
            pipeline {
              agent any
             
              stages {
                stage ('init') {
                  steps {
                    echo 'Hello World'
                  }
                }
              }

              post {
                always {
                  script {
                    echo 'echo step before emailext step'
                    emailext(subject: 'Test email', to: 'invalid@invalid.com')
                  }
                }
              }
            }
            {code}

            *Screenshot
             !image-2017-10-05-13-38-27-385.png|thumbnail!

            *Original Request*
            Here the correct classic UI console log:
             !image-2017-10-03-08-12-06-625.png|thumbnail!

            Here the Blue Ocean UI with different output:
             !image-2017-10-03-08-13-28-073.png|thumbnail!

            And this is the end of the declarative pipeline code:
            {code:java}
              post {
                failure {
                  script {
                    ...
                  }
                }
                always {
                  script {
                    ...
                    if (...) {
                      echo 'Keeping this build forever and sending specific email notification with build report...'
                      ...
                      emailext(subject: '... Recovery Build Report', to: toEmails, attachLog: true, body: htmlBody, mimeType: Constants.CONTENT_TYPE_TEXT_HTML)
                    } else {
                      ...
                    }
                  ...
            {code}
            jamesdumay James Dumay made changes -
            Description *Problem*
            Steps will appear out of order from where they were defined in the Jenkinsfile.

            *Jenkinsfile*
            {code}
            pipeline {
              agent any
             
              stages {
                stage ('init') {
                  steps {
                    echo 'Hello World'
                  }
                }
              }

              post {
                always {
                  script {
                    echo 'echo step before emailext step'
                    emailext(subject: 'Test email', to: 'invalid@invalid.com')
                  }
                }
              }
            }
            {code}

            *Screenshot
             !image-2017-10-05-13-38-27-385.png|thumbnail!

            *Original Request*
            Here the correct classic UI console log:
             !image-2017-10-03-08-12-06-625.png|thumbnail!

            Here the Blue Ocean UI with different output:
             !image-2017-10-03-08-13-28-073.png|thumbnail!

            And this is the end of the declarative pipeline code:
            {code:java}
              post {
                failure {
                  script {
                    ...
                  }
                }
                always {
                  script {
                    ...
                    if (...) {
                      echo 'Keeping this build forever and sending specific email notification with build report...'
                      ...
                      emailext(subject: '... Recovery Build Report', to: toEmails, attachLog: true, body: htmlBody, mimeType: Constants.CONTENT_TYPE_TEXT_HTML)
                    } else {
                      ...
                    }
                  ...
            {code}
            *Problem*
            Steps will appear out of order from where they were defined in the Jenkinsfile.

            *Jenkinsfile*
            {code}
            pipeline {
              agent any
             
              stages {
                stage ('init') {
                  steps {
                    echo 'Hello World'
                  }
                }
              }

              post {
                always {
                  script {
                    echo 'echo step before emailext step'
                    emailext(subject: 'Test email', to: 'invalid@invalid.com')
                  }
                }
              }
            }
            {code}

            *Screenshot*
             !image-2017-10-05-13-38-27-385.png|thumbnail!

            *Original Request*
            Here the correct classic UI console log:
             !image-2017-10-03-08-12-06-625.png|thumbnail!

            Here the Blue Ocean UI with different output:
             !image-2017-10-03-08-13-28-073.png|thumbnail!

            And this is the end of the declarative pipeline code:
            {code:java}
              post {
                failure {
                  script {
                    ...
                  }
                }
                always {
                  script {
                    ...
                    if (...) {
                      echo 'Keeping this build forever and sending specific email notification with build report...'
                      ...
                      emailext(subject: '... Recovery Build Report', to: toEmails, attachLog: true, body: htmlBody, mimeType: Constants.CONTENT_TYPE_TEXT_HTML)
                    } else {
                      ...
                    }
                  ...
            {code}
            jamesdumay James Dumay made changes -
            Description *Problem*
            Steps will appear out of order from where they were defined in the Jenkinsfile.

            *Jenkinsfile*
            {code}
            pipeline {
              agent any
             
              stages {
                stage ('init') {
                  steps {
                    echo 'Hello World'
                  }
                }
              }

              post {
                always {
                  script {
                    echo 'echo step before emailext step'
                    emailext(subject: 'Test email', to: 'invalid@invalid.com')
                  }
                }
              }
            }
            {code}

            *Screenshot*
             !image-2017-10-05-13-38-27-385.png|thumbnail!

            *Original Request*
            Here the correct classic UI console log:
             !image-2017-10-03-08-12-06-625.png|thumbnail!

            Here the Blue Ocean UI with different output:
             !image-2017-10-03-08-13-28-073.png|thumbnail!

            And this is the end of the declarative pipeline code:
            {code:java}
              post {
                failure {
                  script {
                    ...
                  }
                }
                always {
                  script {
                    ...
                    if (...) {
                      echo 'Keeping this build forever and sending specific email notification with build report...'
                      ...
                      emailext(subject: '... Recovery Build Report', to: toEmails, attachLog: true, body: htmlBody, mimeType: Constants.CONTENT_TYPE_TEXT_HTML)
                    } else {
                      ...
                    }
                  ...
            {code}
            *Problem*
            Steps will appear out of order from where they were defined in the Jenkinsfile.

            *Jenkinsfile*
            {code}
            pipeline {
              agent any
             
              stages {
                stage ('init') {
                  steps {
                    echo 'Hello World'
                  }
                }
              }

              post {
                always {
                  script {
                    echo 'echo step before emailext step'
                    emailext(subject: 'Test email', to: 'invalid@invalid.com')
                  }
                }
              }
            }
            {code}

            *Screenshot*
             !image-2017-10-05-13-38-27-385.png!

            *Original Request*
            Here the correct classic UI console log:
             !image-2017-10-03-08-12-06-625.png|thumbnail!

            Here the Blue Ocean UI with different output:
             !image-2017-10-03-08-13-28-073.png|thumbnail!

            And this is the end of the declarative pipeline code:
            {code:java}
              post {
                failure {
                  script {
                    ...
                  }
                }
                always {
                  script {
                    ...
                    if (...) {
                      echo 'Keeping this build forever and sending specific email notification with build report...'
                      ...
                      emailext(subject: '... Recovery Build Report', to: toEmails, attachLog: true, body: htmlBody, mimeType: Constants.CONTENT_TYPE_TEXT_HTML)
                    } else {
                      ...
                    }
                  ...
            {code}
            Hide
            jamesdumay James Dumay added a comment -

            Thanks for the test case

            Show
            jamesdumay James Dumay added a comment - Thanks for the test case
            jamesdumay James Dumay made changes -
            Sprint Blue Ocean 1.4 - beta 3 [ 416 ] Blue Ocean 1.4 - beta 4 [ 441 ]
            Hide
            kshultz Karl Shultz added a comment -

            Testing Notes:
            The reporter of this issue has kindly provided a test Jenkinsfile to use. Thanks, Reinhold Füreder

            Show
            kshultz Karl Shultz added a comment - Testing Notes: The reporter of this issue has kindly provided a test Jenkinsfile to use. Thanks, Reinhold Füreder
            kshultz Karl Shultz made changes -
            Labels testing-notes-reviewed
            Show
            vivek Vivek Pandey added a comment - Fixed in JENKINS-49297 , PR https://github.com/jenkinsci/blueocean-plugin/pull/1694 .
            vivek Vivek Pandey made changes -
            Link This issue relates to JENKINS-49297 [ JENKINS-49297 ]
            vivek Vivek Pandey made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            vivek Vivek Pandey made changes -
            Sprint Blue Ocean - Candidates [ 441 ] Blue Ocean 1.5 - beta 3 [ 491 ]
            vivek Vivek Pandey made changes -
            Assignee Vivek Pandey [ vivek ]
            jbriden Jenn Briden made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

              People

              • Assignee:
                vivek Vivek Pandey
                Reporter:
                reinholdfuereder Reinhold Füreder
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: