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

Pipeline script post handler - changed action always fired

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Jenkins server 2.98, Pipeline plugin 2.5, Pipeline step API 2.14

      In a pipeline script I have the following post handler logic.

         post {                                               
             always {                                                          
                 junit 'results/*.xml' 
             }                             
             changed {                                                      
                 emailext body: '$DEFAULT_CONTENT', subject: '$DEFAULT_SUBJECT', to: 'email@domain.com'                                             
             }                                                            
         }   
      

      What used to happen is that emails would only be sent if the state changed. So if the build results were as follows

      • FAILED
      • UNSTABLE
      • UNSTABLE
      • UNSTABLE
      • FAILED
      • UNSTABLE
      • FAILED
      • UNSTABLE
      • UNSTABLE

      Then email would only be sent on the state change from UNSTABLE->FAILED or FAILED->UNSTABLE. Emails would not be sent when the state was UNSTABLE->UNSTABLE.

      However our Jenkins server was updated over Christmas and as a result I am seeing an email being sent regardless of the state remaining the same. I could work around this by using something similar to

      if (currentBuild.currentResult.toString() != currentBuild.getPreviousBuild.getResult().toString()) {
      // email
      }

       

      However the previous behaviour was what I was expecting to see. Changes in the pipeline plugins seem to be

      Plugin Previous version New version
      Pipeline: API 2.23 2.24
      Pipeline: Basic Steps 2.5 2.6
      Pipeline: Build Step 2.5.1 2.6
      Pipeline: Declarative 1.2.2 1.2.5
      Pipeline: Declarative Extension Points API 1.2.2 1.2.5
      Pipeline: Groovy 2.41 2.42
      Pipeline: Nodes and Processes 2.11 2.17
      Pipeline: Shared Groovy Libraries 2.8 2.9
      Pipeline: Stage Step 2.2 2.3
      Pipeline: Step API 2.13 2.14

            abayer Andrew Bayer
            ismith Ian Smith
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: