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

email-ext sends wrong build status when called from declarative script

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • token-macro-plugin
    • None
    • Jenkins 2.61
      email-ext plugin 2.57.2

      I have a simple declarative script:

      pipeline {
          agent { label "mypc1" }
          stages {
              stage('build') {
                  steps {
                      sh '''
                          python --version
                      '''
                  }
              }
          }
          post {
      
              // We want to send notification emails to daldrich and the culprits.
              // The subject and body use the default content set in 'Jenkins > Configure System'
      
              success {
                  script{ emailext (body: '${DEFAULT_CONTENT}',
                                    recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                    subject: '${DEFAULT_SUBJECT}',
                                    to: 'daldrich')
                  }
              }
              failure {
                  script{ emailext (body: '${DEFAULT_CONTENT}',
                                    recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                    subject: '${DEFAULT_SUBJECT}',
                                    to: 'daldrich')
                  }
              }
              unstable {
                  script{ emailext (body: '${DEFAULT_CONTENT}',
                                    recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                    subject: '${DEFAULT_SUBJECT}',
                                    to: 'daldrich')
                  }
              }
              changed {
                  script{ emailext (body: '${DEFAULT_CONTENT}',
                                    recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                    subject: '${DEFAULT_SUBJECT}',
                                    to: 'daldrich')
                  }
              }
          }
      }
      

      Problem 1

      The email subject uses : '${DEFAULT_SUBJECT}', which ends with ‘$BUILD_STATUS!’. In the received email for a successful build the build status is ‘Building!’:

      Experimental_LedaAP_gcc_build » trunk - Build # 43 - Building!

      This is in ‘post’ so I expect the status to be ‘Success!’.

      abayer wrote on IRC:

      The build hasn't actually finished yet at that point. email-ext probably needs to be changed to be aware of that.

      So I think there is a bug in the plugin.

      Problem 2

      I'm expecting the email to be sent to daldrich and the culprits. There are culprits since there were svn commits by another user since the job last ran successfully.

      On Failure, the recipients are daldrich and the culprits, which is correct.

      When the failure is Fixed, the recipients are only daldrich - the culprits are not included, which is incorrect. (In a traditional Jenkins job, recipients and culprits are notified of Fixed, if they are specified in the job configuration).

      I think this is also a bug in the plugin.

          [JENKINS-44322] email-ext sends wrong build status when called from declarative script

          David Aldrich created issue -
          David Aldrich made changes -
          Description Original: I have a simple declarative script:

          {code}
          pipeline {
              agent { label "carmepc1" }
              stages {
                  stage('build') {
                      steps {
                          sh 'python --version'
                      }
                  }
              }
              post {
                  success {
                      // We want to send notification emails to daldrich and the culprits.
                      // The subject and body use the default content set in 'Jenkins > Configure System'
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
              }
          }
          {code}

          *Problem 1*

          The email subject uses : '$\{DEFAULT_SUBJECT\}', which ends with ‘$BUILD_STATUS!’ . In the received email the build status is ‘Building!’. This is in ‘post’ so I expect the status to be ‘Success!’.

          abayer wrote on IRC:

          {panel}
          The build hasn't actually finished yet at that point. email-ext probably needs to be changed to be aware of that.
          {panel}

          So I think there is a bug in the plugin.

          *Problem 2*

          I'm expecting the email to be sent to daldrich and the culprits. There are culprits since there were svn commits by another user since the job last ran. But the job only sent emails to daldrich:

          {code}
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] stage
          [Pipeline] { (build)
          [Pipeline] sh
          [ntal_LedaAP_gcc_build_trunk-USLWUOYL7YVX3I7JSGOWM7HFTAUAJAGDYQW3ZWS5KMKKC5DUTV4A] Running shell script
          + python --version
          Python 2.7.12
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] stage
          [Pipeline] { (Declarative: Post Actions)
          [Pipeline] script
          [Pipeline] {
          [Pipeline] emailext
          Sending email to: David.Aldrich@EMEA.NEC.COM
          [Pipeline] }
          [Pipeline] // script
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          {code}
           Is this a bug?
          New: I have a simple declarative script:
          {code:java}
          pipeline {
              agent { label "mypc1" }
              stages {
                  stage('build') {
                      steps {
                          sh 'python --version'
                      }
                  }
              }
              post {
                  success {
                      // We want to send notification emails to daldrich and the culprits.
                      // The subject and body use the default content set in 'Jenkins > Configure System'
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
              }
          }
          {code}
          *Problem 1*

          The email subject uses : '$\{DEFAULT_SUBJECT}', which ends with ‘$BUILD_STATUS!’ . In the received email the build status is ‘Building!’. This is in ‘post’ so I expect the status to be ‘Success!’.

          abayer wrote on IRC:
          {panel}
          The build hasn't actually finished yet at that point. email-ext probably needs to be changed to be aware of that.
          {panel}
          So I think there is a bug in the plugin.

          *Problem 2*

          I'm expecting the email to be sent to daldrich and the culprits. There are culprits since there were svn commits by another user since the job last ran. But the job only sent emails to daldrich:
          {code:java}
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] stage
          [Pipeline] { (build)
          [Pipeline] sh
          [ntal_LedaAP_gcc_build_trunk-USLWUOYL7YVX3I7JSGOWM7HFTAUAJAGDYQW3ZWS5KMKKC5DUTV4A] Running shell script
          + python --version
          Python 2.7.12
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] stage
          [Pipeline] { (Declarative: Post Actions)
          [Pipeline] script
          [Pipeline] {
          [Pipeline] emailext
          Sending email to: David.Aldrich@EMEA.NEC.COM
          [Pipeline] }
          [Pipeline] // script
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          {code}
          Is this a bug?
          David Aldrich made changes -
          Description Original: I have a simple declarative script:
          {code:java}
          pipeline {
              agent { label "mypc1" }
              stages {
                  stage('build') {
                      steps {
                          sh 'python --version'
                      }
                  }
              }
              post {
                  success {
                      // We want to send notification emails to daldrich and the culprits.
                      // The subject and body use the default content set in 'Jenkins > Configure System'
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
              }
          }
          {code}
          *Problem 1*

          The email subject uses : '$\{DEFAULT_SUBJECT}', which ends with ‘$BUILD_STATUS!’ . In the received email the build status is ‘Building!’. This is in ‘post’ so I expect the status to be ‘Success!’.

          abayer wrote on IRC:
          {panel}
          The build hasn't actually finished yet at that point. email-ext probably needs to be changed to be aware of that.
          {panel}
          So I think there is a bug in the plugin.

          *Problem 2*

          I'm expecting the email to be sent to daldrich and the culprits. There are culprits since there were svn commits by another user since the job last ran. But the job only sent emails to daldrich:
          {code:java}
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] stage
          [Pipeline] { (build)
          [Pipeline] sh
          [ntal_LedaAP_gcc_build_trunk-USLWUOYL7YVX3I7JSGOWM7HFTAUAJAGDYQW3ZWS5KMKKC5DUTV4A] Running shell script
          + python --version
          Python 2.7.12
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] stage
          [Pipeline] { (Declarative: Post Actions)
          [Pipeline] script
          [Pipeline] {
          [Pipeline] emailext
          Sending email to: David.Aldrich@EMEA.NEC.COM
          [Pipeline] }
          [Pipeline] // script
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          {code}
          Is this a bug?
          New: I have a simple declarative script:
          {code:java}
          pipeline {
              agent { label "mypc1" }
              stages {
                  stage('build') {
                      steps {
                          sh '''
                              python --version
                          '''
                      }
                  }
              }
              post {

                  // We want to send notification emails to daldrich and the culprits.
                  // The subject and body use the default content set in 'Jenkins > Configure System'

                  success {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
                  failure {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
                  unstable {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
                  changed {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
              }
          }
          {code}
          *Problem 1*

          The email subject uses : '$\{DEFAULT_SUBJECT}', which ends with ‘$BUILD_STATUS!’ . In the received email the build status is ‘Building!’:
          {panel}
          Experimental_LedaAP_gcc_build » trunk - Build # 43 - Building!
          {panel}
          This is in ‘post’ so I expect the status to be ‘Success!’.

          abayer wrote on IRC:
          {panel}
          The build hasn't actually finished yet at that point. email-ext probably needs to be changed to be aware of that.
          {panel}
          So I think there is a bug in the plugin.

          *Problem 2*

          I'm expecting the email to be sent to daldrich and the culprits. There are culprits since there were svn commits by another user since the job last ran successfully.

          On Failure, the recipients are daldrich and the culprits, which is correct.

          When the failure is Fixed, the recipients are only daldrich - the culprits are not included, +which is incorrect+. (In a traditional Jenkins job, recipients +and+ culprits are notified of Fixed, if they are specified in the job configuration).

          I think this is also a bug in the plugin.
          David Aldrich made changes -
          Description Original: I have a simple declarative script:
          {code:java}
          pipeline {
              agent { label "mypc1" }
              stages {
                  stage('build') {
                      steps {
                          sh '''
                              python --version
                          '''
                      }
                  }
              }
              post {

                  // We want to send notification emails to daldrich and the culprits.
                  // The subject and body use the default content set in 'Jenkins > Configure System'

                  success {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
                  failure {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
                  unstable {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
                  changed {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
              }
          }
          {code}
          *Problem 1*

          The email subject uses : '$\{DEFAULT_SUBJECT}', which ends with ‘$BUILD_STATUS!’ . In the received email the build status is ‘Building!’:
          {panel}
          Experimental_LedaAP_gcc_build » trunk - Build # 43 - Building!
          {panel}
          This is in ‘post’ so I expect the status to be ‘Success!’.

          abayer wrote on IRC:
          {panel}
          The build hasn't actually finished yet at that point. email-ext probably needs to be changed to be aware of that.
          {panel}
          So I think there is a bug in the plugin.

          *Problem 2*

          I'm expecting the email to be sent to daldrich and the culprits. There are culprits since there were svn commits by another user since the job last ran successfully.

          On Failure, the recipients are daldrich and the culprits, which is correct.

          When the failure is Fixed, the recipients are only daldrich - the culprits are not included, +which is incorrect+. (In a traditional Jenkins job, recipients +and+ culprits are notified of Fixed, if they are specified in the job configuration).

          I think this is also a bug in the plugin.
          New: I have a simple declarative script:
          {code:java}
          pipeline {
              agent { label "mypc1" }
              stages {
                  stage('build') {
                      steps {
                          sh '''
                              python --version
                          '''
                      }
                  }
              }
              post {

                  // We want to send notification emails to daldrich and the culprits.
                  // The subject and body use the default content set in 'Jenkins > Configure System'

                  success {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
                  failure {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
                  unstable {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
                  changed {
                      script{ emailext (body: '${DEFAULT_CONTENT}',
                                        recipientProviders: [[$class: 'CulpritsRecipientProvider']],
                                        subject: '${DEFAULT_SUBJECT}',
                                        to: 'daldrich')
                      }
                  }
              }
          }
          {code}
          *Problem 1*

          The email subject uses : '$\{DEFAULT_SUBJECT}', which ends with ‘$BUILD_STATUS!’. In the received email for a successful build the build status is ‘Building!’:
          {panel}
          Experimental_LedaAP_gcc_build » trunk - Build # 43 - Building!
          {panel}
          This is in ‘post’ so I expect the status to be ‘Success!’.

          abayer wrote on IRC:
          {panel}
          The build hasn't actually finished yet at that point. email-ext probably needs to be changed to be aware of that.
          {panel}
          So I think there is a bug in the plugin.

          *Problem 2*

          I'm expecting the email to be sent to daldrich and the culprits. There are culprits since there were svn commits by another user since the job last ran successfully.

          On Failure, the recipients are daldrich and the culprits, which is correct.

          When the failure is Fixed, the recipients are only daldrich - the culprits are not included, +which is incorrect+. (In a traditional Jenkins job, recipients +and+ culprits are notified of Fixed, if they are specified in the job configuration).

          I think this is also a bug in the plugin.
          David van Laatum made changes -
          Component/s New: token-macro-plugin [ 15832 ]
          Component/s Original: email-ext-plugin [ 15538 ]
          Assignee Original: David van Laatum [ davidvanlaatum ] New: Alex Earl [ slide_o_mix ]
          Alex Earl made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Benjamin Kihm made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]
          Benjamin Kihm made changes -
          Link New: This issue is caused by JENKINS-56402 [ JENKINS-56402 ]
          Benjamin Kihm made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Reopened [ 4 ] New: Closed [ 6 ]

            slide_o_mix Alex Earl
            davida2009 David Aldrich
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: