简体   繁体   中英

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?

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'"/ ... />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM