title: Creating a rollback build for TeamCity
body: <p>We have a nightly TeamCity build which releases the latest code to our test website, restores the database to match production, then applies any schema and data changes we have in TFS.
  If this nightly build fails, the website is down until we manually fix the code and/or the database scripts and restart the build.</p>
  
  <p>What I'd like is to automatically rollback to the last successful build so the website is available despite of any build break.</p>
  
  <p>After spending a bit of time investigating, here's my proposed solution:</p>
  
  <ol>
  <li>Nightly build runs, creating a new label in TFS (something like Nightly-build-{build number})</li>
  <li>Create a new TeamCity build which triggers after the nightly build runs</li>
  <li>Find the last successful nightly build number</li>
  <li>Get the version relating to that build number's label in TFS</li>
  <li>Rollback builds (it doesn't matter if the nightly build just finished successfully)</li>
  </ol>
  
  <p>What I don't know is how to have the rollback build get the version based off a label.</p>
  
  <p>Any help for this, or another solution, would be appreciated.</p>
  
  <p>Cheers.</p>