title: Can a Jenkins job be aborted with success result?
body: <p>In a declarative pipeline, using a multibranch job and a Jenkinsfile, can the job be <strong>aborted</strong> with a <code>success</code> exit code rather than a <code>failure</code> exit code?</p>
  
  <p>In the below stage, I basically check if the commit that started the job contains "ci skip", and if it does I want to abort the job. </p>
  
  <p>Using <code>error</code> aborts the job but also marks it as such (red row). I'd like this job to be marked with a green row.</p>
  
  <pre><code>stage ("Checkout SCM") {
     steps {
        script {
           checkout scm
           result = sh (script: "git log -1 | grep '.*\\[ci skip\\].*'", returnStatus: true) 
           if (result == 0) {
              error ("'ci skip' spotted in git commit. Aborting.")
           }
        }
     }
  }
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>Instead of the above, I am now trying to simply skip all stages in case the git commit contains "ci skip". My understanding is that if the result in <code>expression</code> is <code>false</code>, it should skip the stage...</p>
  
  <pre><code>pipeline {
      environment {
          shouldBuild = "true"
      }
      ...
      ...
      stage ("Checkout SCM") {
          steps {
              script {
                  checkout scm
                  result = sh (script: "git log -1 | grep '.*\\[ci skip\\].*'", returnStatus: true) 
                  if (result == 0) {
                      echo ("'ci skip' spotted in git commit. Aborting.")
                      shouldBuild = "false"
                  }
              }
          }
      }
  
      stage ("Unit tests") {
          when {
              expression {
                  return shouldBuild
              }
          }
          steps {
              ...
          }
      }
      ...
      ...
  }
  </code></pre>