title: How to mark the jenkins build unstable with groovy postbuild
body: <p>I'm running test cases with nosetests in Jenkins. In general, it will have 100 test cases and I want to mark the build unstable when less than 20 test cases failed. If more than 20 test cases failed, then, mark the build failed. </p>
  
  <p>The command I ran:</p>
  
  <pre><code>nosetests test.py --tc-file config.yml --tc-format yaml
  </code></pre>
  
  <p>First of all, I tried to just change the status of the build to Unstable but it still failed. </p>
  
  <p>The groovy script I used:</p>
  
  <pre><code>manager.addWarningBadge("Thou shalt not use deprecated methods.")
  manager.createSummary("warning.gif").appendText("&lt;h1&gt;You have been warned!&lt;/h1&gt;", false, false, false, "red")
  manager.buildUnstable()
  </code></pre>
  
  <p>The first two lines of code are executed, but the job is still marked as Failed. </p>
  
  <p>Is there anything wrong with my jenkins config? Or the groovy postbuild plugin does not work with nosetest?</p>
  
  <p>This is the console output:</p>
  
  <pre><code>FAILED (failures=2)
  Build step 'Execute shell' marked build as failure
  Build step 'Groovy Postbuild' marked build as failure
  Finished: FAILURE
  </code></pre>