I have a listener waiting for the buildStarted event so that I can perform a pre-requisite check before the build is run. If the check fails, I want the build to fail with an error message. When I use SRunningBuild.stop() it stops the build and shows the error message, which is almost perfect. However, the build status shows up as cancelled in the build history, and you can only see this if you have the "include canceled builds" option selected. If a user doesn't have it selected, it looks like the build was never run, which is confusing.
Alternatively, I have tried using SRunningBuild.setBuildStatus(Status.ERROR) which fails the build so it shows up in the history properly, but I don't have the option of providing a message as to why it failed. Also, even after I issue the command it continues to run the build until it is finished.
What I want is the functionality of calling stop(), but to have the build status show as failure instead of cancelled. Is this possible?