title: How to send notifications in Jenkins pipeline when build recovers?
body: <p>I want to send notifications from my Jenkins pipeline build when the job recovers. Meaning when the current build is successful and the last build was erroneous (failed, aborted etc).</p>
  
  <p>I know how to send notifications. I think my question boils down to how to check the status of the previous build, but I might be mistaken.</p>
  
  <p>I have tried "currentBuild.rawBuild.getPreviousBuild()?.getResult()", but got exception "org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper getRawBuild". If I turn sandbox off, it should work. Would it be possible with the sandbox?</p>