Access Stage results in Workflow/ Pipeline plugin
<p>I have a pipeline with different stages. I want the current job to check how many stages have passed in the previous build and log it in the console? </p>

<p>Consider this is my current pipeline</p>

<pre><code>node(){
 stage "1"
 do something

 stage "2"
 do something else
}
</code></pre>

<p>I want a groovy script to give my something like this</p>

<pre><code>println currentBuild.previousBuild.getStage("1").result
</code></pre>

<p>The purpose of my code is track successes &amp; failures in different stages across my builds. Are there any alternatives to this approach? </p>