Revert bach check in after build fail
Hi,
I am using Continuous integration technique to build my code after every check in.
My e-mail:amitsharma.mca@gmail.com
Hi,
I am using Continuous integration technique to build my code after every check in.
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
just one additional bit... you'll have to include the TF assignment as well:
<!-- TF.exe assignment -->
<TF>"$(TeamBuildRefPath)\..\tf.exe"</TF>
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
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.
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........
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