Revert bach check in after build fail

Hi,

I am using Continuous integration technique to build my code after every check in.

I need your help in one regard. If the team build failed due to recent checked in file then i need to revert back this check-in so that i can have buildable code available in source control every time. So is there any way to achieve this through programatically or by any other way.
My e-mail:amitsharma.mca@gmail.com
[578 byte] By [amsharma] at [2007-12-24]
# 1

This is a piece from one of my build scripts, which updates all version info files and checks them into TFS's SCM system, if everything goes well ;)... if there are breaks, the bit below will revert the pending changes... seems to work fine.

Anyway... BeforeOnBuildBreak is where you should start.

<!-- In case of Build failure, the AfterCompile target is not executed. Undo the changes -->
<Target Name="BeforeOnBuildBreak" Condition="'$(IsDesktopBuild)'!='true'">
<Exec WorkingDirectory="$(SolutionRoot)"
Command="$(TF) undo /noprompt /recursive AssemblyInfo.cs"/>
<Exec WorkingDirectory="$(SolutionRoot)"
Command="$(TF) undo /noprompt /recursive build.wxi"/>
<Exec WorkingDirectory="$(SolutionRoot)"
Command="$(TF) undo /noprompt /recursive *.rc.h"/>
<Message Text="****"></Message>
<Message Text="==== Build Failure - Undo Checkin"></Message>
<Message Text="****"></Message>
</Target>

-dto

dto at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 2

just one additional bit... you'll have to include the TF assignment as well:

<!-- TF.exe assignment -->

<TF>&quot;$(TeamBuildRefPath)\..\tf.exe&quot;</TF>

dto at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 3

You would need to use the Team Foundation Power Toy, tfpt.exe, to revert the checkin.

You can get it at http://go.microsoft.com/?linkid=5431080. The documentation and tfpt.exe are under C:\Program Files\Microsoft Team Foundation Server Power Toys.

Buck

BuckHodges at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 4

Hi Buck,

tfpt.exe seems to be work on client side but i want when a team build fail on TFS then that check-in should be revert back such that all check in files should be replaced by their previous version. How can i acheive server side revert back in case of build failure.

amsharma at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 5

Hi, You are using undo command of tf.exe which does undo if there is any pending changes but in my case as checkin has been already done and after that build has fired therefore if build fails then i can not use undo command because there is no pending checkin. I need something like if the team build has failed on TFS then the currently checked in file should be revert back with there previous version.

Please help........

amsharma at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...
# 6

The tfpt rollback command is the only way to rollback a checkin with v1 (short of writing your own). You would need to use the Exec task in MSBuild to invoke tfpt rollback. The most critical part will be determining which checkin you want to revert, as you wouldn't want to roll back the wrong one. Determining which one to roll back depends on your CI approach. If you are passing through the changeset number that triggered the CI build, then you know what you need to rollback.

Buck

BuckHodges at 2007-10-8 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Build Automation...

Visual Studio Team System

Site Classified