Search

just show me the code

Showing posts with label tfs. Show all posts
Showing posts with label tfs. Show all posts

Thursday, April 23, 2009

TFS Fail a build AND create a work item when unit test fails

thanks to http://social.msdn.microsoft.com/forums/en-US/tfsbuild/thread/b6fa6aa8-1861-4cd0-b9bb-4eeb64432651/




  229   <Target Name="AfterTest">
  230     <!-- Refresh the build properties. -->
  231     <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
  232                         BuildUri="$(BuildUri)"
  233                         Condition=" '$(IsDesktopBuild)' != 'true' ">
  234       <Output TaskParameter="TestSuccess"
  235               PropertyName="TestSuccess" />
  236     </GetBuildProperties>

  237 
  238     <!-- Set CompilationStatus to Failed if TestSuccess is false. -->
  239     <SetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
  240                         BuildUri="$(BuildUri)"
  241                         CompilationStatus="Failed"
  242                         Condition=" '$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true' ">
  243     </SetBuildProperties>
  244     <CreateNewWorkItem
  245       BuildNumber="$(BuildNumber)"
  246       BuildURi="$(BuildURI)"
  247       Description="The CreateNewWorkItem task created this bug."
  248       TeamProject="$(TeamProject)"
  249       TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
  250       Title="Unit Test Failure in $(BuildNumber)"
  251       WorkItemFieldValues="$(WorkItemFieldValues)"
  252       WorkItemType="$(WorkItemType)"
  253       Condition=" '$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true' ">
  254     </CreateNewWorkItem>
  255   </Target>

Thursday, January 29, 2009

Fail a Build when your Test Fails

Fail a Build when your Test Fails
ref: http://blogs.msdn.com/aaronhallberg/archive/2007/11/05/how-to-fail-a-build-when-tests-fail.aspx

Why
When a team build compiles with no errors, it is a success. If the test fail it gets marked as partially successful. Most would rather a failed test to mark the build as Failed.


Step1: Change your Target
The following code should be pasted into the bottom of your Team Build poject file and edited as necessary.

  252   <Target Name="AfterTest"> 
  253     <!-- Refresh the build properties. -->
  254     <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
  255       BuildUri="$(BuildUri)"
  256       Condition=" '$(IsDesktopBuild)' != 'true' ">
  257       <Output TaskParameter="TestSuccess" PropertyName="TestSuccess" />
  258     </GetBuildProperties>
  259
  260     <!-- Set CompilationStatus to Failed if TestSuccess is false. -->
  261     <SetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
  262       BuildUri="$(BuildUri)"
  263       CompilationStatus="Failed"
  264       Condition=" '$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true' "  >
  265     </SetBuildProperties>
  266   </Target>

UPDATE
------------------------
http://drycode.blogspot.com/2009/04/tfs-fail-build-when-unit-test-fails.html


Tuesday, January 20, 2009

Auto deploy a TFS build


  
  228   <Target Name="AfterDropBuild">
  229     <CreateProperty Value="\\webdev1\Domains\Xxx_Xxxx_XxxxxXxxxx">
  230       <Output
  231         TaskParameter="Value"
  232         PropertyName="WebPreviewDropLocation"/>
  233     </CreateProperty>
  234     <CreateItem
  235         Include="$(DropLocation)\$(BuildNumber)\Release\_PublishedWebsites\Xxxx.XxxxXxxxx.Web\**\*">
  236       <Output
  237          TaskParameter ="Include"
  238          ItemName ="MyDropFiles"/>
  239     </CreateItem>
  240
  241     <RemoveDir Directories="$(WebPreviewDropLocation)"
  242                Condition="'$(BuildBreak)'!='true'" />
  243     <MakeDir Directories="$(WebPreviewDropLocation)"
  244              Condition="'$(BuildBreak)'!='true'" /> 
  245    <Copy
  246       SourceFiles="@(MyDropFiles)"
  247       DestinationFiles="@(MyDropFiles->'$(WebPreviewDropLocation)\%(RecursiveDir)%(Filename)%(Extension)')" 
  248       Condition="'$(BuildBreak)'!='true'" />
  249   </Target>

Contributors