title: Jenkins-Declarative Pipeline - How to make particular stage failure
body: <p>In my Jenkins declarative pipeline I am performing small validation on Patchnumber being passed in the job parameter. If the patch number is less than 8 Chars, the particular stage should fail. Below is the code for the same. Here I see the Stage is not failing and it proceeds with the next Stage.</p>
  
  <p>How can I make the Stage fail forcefully and terminate the whole Job  execution?</p>
  
  <pre class="lang-groovy prettyprint-override"><code>stage("Validate Patch Number Size")
  {
      steps
      {
          script
          {
              if ( (params.ENGLISH_PATCH_NUMBER).length() == 8 &amp;&amp; (params.BIP_DB_PATCH_NUMBER).length() == 8 &amp;&amp; (params.KO_PATCH_NUMBER).length() == 8) {
                  result = 'valid'
                  echo "Patch number entered meets the recommended size 8 - Status:$result"
              } else {
                  resultStatus = 'Invalid'
                  echo "The patch number size doesnt meet the recommended size 8 - Status: $resultStatus "
                  currentBuild.result='FAILURE'
                  echo "The current status is ${currentBuild.result}"
              }
          }
      }
  }
  </code></pre>