I want to imitate Jenkins’s original behavior of doing things (like sending notifications) when assemblies become unstable / fail or become successful again.
To do this, I need to request the previous build status, which can be done as follows:
currentBuild.rawBuild.getPreviousBuild()?.getResult().toString()
However, it rawBuildmust be a “dangerous” object and thus blacklisted and cannot be executed inside the Groovy sandbox .
Now, since I am loading my Jenkins scripts from SCM, I am unable to deactivate the Groovy sandbox at the level of each project, but only for the whole Jenkins instance (i.e. through this ), and this, of course, is not what I want.
Is there any other way to determine the last build status of a job that conforms to the sandbox principles (and does not include hacks, such as requesting status via the Jenkins REST API) that I skipped?
source
share