title: Capistrano test run failed, but deployment successful
body: <p>I have setup Capistrano for my rails project deployment &amp; I'm running my unit tests from a custom cap task as below.</p>
  
  <pre><code>namespace :deploy do
    desc "Runs test before deploying, can't deploy unless they pass"
    task :run_tests do
  
      puts "--&gt; Running tests, please wait ..."
      unless system "bundle exec rake &gt; log/capistrano.log 2&gt;&amp;1" #' &gt; /dev/null'
        puts "--&gt; Tests failed. Run `cat log/capistrano.log` to see what went wrong."
        exit
      else
        puts "--&gt; Tests passed"
      end
  
      puts "--&gt; All tests passed"
    end
  end
  </code></pre>
  
  <p>If there is a unit test failure in the system, deployment will not proceed further, but in <code>jenkins</code> the build is showing in blue color. That means build is successful.</p>
  
  <p>How can I notify <code>jenkins</code> that build ended with errors?</p>