Halt a jenkins pipeline job early
<p>In our Jenkins Pipeline job we have a couple of stages, and what I would like is if any of the stages fail, then to have the build stop and not continue on to the further stages.</p>

<p>Here's an example of one of the stages:</p>

<pre class="lang-groovy prettyprint-override"><code>stage('Building') {
    def result = sh returnStatus: true, script: './build.sh'
    if (result != 0) {
        echo '[FAILURE] Failed to build'
        currentBuild.result = 'FAILURE'
    }
}
</code></pre>

<p>The script will fail, and the build result will update, but the job continues on to the next stages. How can I abort or halt the job when this happens?</p>