Search

just show me the code

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>

No comments:

Post a Comment

Contributors