title: Jenkins declarative pipeline conditional post action
body: <p>I am using Jenkins declarative pipeline and want to perform some post build actions depending on the build status.</p>
  
  <p>To be more precise, I want to send an email when the build status changed (from success to failure, or success to unstable, or failure to success).</p>
  
  <p>Here is my pipeline:</p>
  
  <pre class="lang-java prettyprint-override"><code>pipeline {
      agent none
      stages {
          stage('test') {
              agent any
              steps {                
                  sh './tests.sh'
              }
          }
      }
      post {
          changed {
              // Send different emails depending on build status
              // Success       -&gt; anything else
              // Anything else -&gt; Success
          }
      }
  }
  </code></pre>
  
  <p>Any idea ?</p>