title: Access which stage failed in previous Jenkins build
body: <p>I have written a Jenkinsfile script which gets whether documents are updated or code is updated in the current Github commit and starts all the stages accordingly. If only documents are updated I don't run the code testing stage again.</p>
  
  <p>So now if the previous build failed and now in the current Git commit only documents are updated then it will not run the code testing stage. So I want a method/way to know which stage failed during the last Jenkins build and if needed run the current Jenkins build.</p>
  
  <p><a href="https://i.stack.imgur.com/aLNiA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/aLNiA.png" alt="enter image description here"></a></p>
  
  <p>For example if the code testing stage failed in the previous build, I'll need to run the code testing stage for this build, otherwise I can just run the documents zipping stage.</p>