title: How to make jenkins fail at a failing windows batch command?
body: <p>I use some windows batch commands in jenkins, where each of the commands could fail. In order to make the jenkins job fail on each step, these batch commands look like follows: </p>
  
  <pre><code>net use m: \\%IP_ADDRESS%\Whatever %PASSWORD% /user:%USERNAME%
  if ERRORLEVEL 1 exit 1
  mkdir m:\Install
  if ERRORLEVEL 1 exit 1
  copy /b %LOCAL_TEMP%\%INSTALLER_EXE% m:\Install\%INSTALLER_EXE% 
  if ERRORLEVEL 1 exit 1
  net use m: /D
  if ERRORLEVEL 1 exit 1
  </code></pre>
  
  <p>In other words: I seem to check every single batch command if it has failed, and then to exit with errorcode 1 if neccessary. Is there a more senseful/convenient/better way to achieve this?</p>
  
  <p>If I do not check every single step and exit, jenkins will execute the following batch command.</p>