title: Execute Final script only on build failure
body: <p>I want to execute an arbitrary shell script, but I only want it to run on build failure.  Is there some way to either:</p>
  
  <ul>
  <li>Set up Bamboo to run this script only on build failure</li>
  <li>Or check from within the script whether the build was successful.  Perhaps an environment/build variable?</li>
  </ul>
  
  <p>Thoughts and ideas appreciated!</p>