Derek Smith
Derek Smith

Reputation: 231

Team City Prevent Build Step From Running

I am working setting up my continuous integration server using Teamcity and I have three steps for my build (.NET/VS2010/MSBUILD)

  1. Use MSBUILD to build my solution.
  2. Run NUnit Tests.
  3. Use MSBUILD to do a Web deploy of my projects.

The issue I am trying to solve is to prevent step 3 from running if any of the test fail. Is this possible?

Upvotes: 4

Views: 1503

Answers (1)

sll
sll

Reputation: 62484

You can do this using NUnit MsBuild Community task by handling Output parameter "ExitCode" and then executing MSBuild Error Task depends on "ExitCode" or execute Deploy task/targets depends on this condition, so it is up to you.

Error task:

Stops a build and logs an error based on an evaluated conditional statement. The Error task allows MSBuild projects issue error text to loggers and stop build execution

<!-- Build -->
<Build .... />

<!-- Run tests -->
<Nunit ....>
   <Output TaskParameter="ExitCode" 
           PropertyName="NUnitResult" />

<!-- Stop build in case of error whilst tests run -->    
<Error Text="Tests failed"
       Code="$(NUnitResult)"
       Condition="'$(NUnitResult)' != '0'"/>

<!-- Deploy -->    
<Deploy Condition="'$(NUnitResult)' != '0'"/ ... />

Upvotes: 2

Related Questions