title: How to stop a Jenkins Pipeline build with using a closure processor
body: <p>How can I have a closure stop a build as aborted without looking like a failure?</p>
  
  <p>In my original Jenkins file I have something like this:</p>
  
  <pre><code>node() {
   println 'should print'
   if (shouldStop()) {
     return
   }
   println 'should NOT print'
  }
  
  # Output
  should print
  </code></pre>
  
  <p>The return out of the node block ends the build with whatever status is presently has and does not perform the additional actions.</p>
  
  <p>If I have a closure in the mix things the unwanted code still executes</p>
  
  <pre><code>withMyAction(closure) {
   def result
   try {
     prepareEnv()
     result = closure()
   } finally {
    cleanUp()
   }
   return result
  }
  
  node() {
   println 'should print'
   withMyAction {
    if (shouldStop()) {
      return
    }
   }
   println 'should NOT print'
  }
  
  # Output
  should print
  should NOT print
  </code></pre>
  
  <p>It seems that my options are</p>
  
  <ul>
  <li>Stop via <code>throw new Exception</code> or <code>error()</code></li>
  <li>Wrap my downstream sections of the job in <code>if status == ...</code></li>
  </ul>
  
  <p>Is there an approach where I can gracefully stop the build early without using <code>return</code> from Jenkinsfile as my approach?</p>