title: How do I know which stage of jenkins pipeline has failed
body: <p>In my Jenkins pipelines I generally use <code>post</code> declarative function to send me an email incase the pipeline has failed. </p>
  
  <p>A simple syntax of the <code>post</code> function is as under:</p>
  
  <pre><code>post {
      failure {
          mail to: 'team@example.com',
               subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
               body: "Something is wrong with ${env.BUILD_URL}"
      }
  }
  </code></pre>
  
  <p>In the above email, I also want to mention which stage (lets say the pipeline has 5 to 6 stages) of the pipeline has failed. How can I do that? Any help is much appreciated.</p>
  
  <p>An extension to the above requirement will be to provide the user with the actual error log (of the stage that has failed) also as a part of the failure notification email.</p>
  
  <p>Idea is, when a user receives a failure notification from jenkins, he should know which stage of the pipeline has failed along with the error log.</p>
  
  <p>Thanks in advance.</p>