I have a Jenkins pipeline which has multiple stages, for example:
node(\"nodename\") { stage(\"Checkout\") { git .... } stage(\"Check Preconditions
Following this documentation from Jenkins, you should be able to generate an error to stop the build and set the build result like this:
currentBuild.result = 'ABORTED'
Hope that helps.