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).
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.
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?