How can I let a teamcity command line build step pass if the exit code is not zero?

There's two ways:

  1. In that Build Configuration, go to the Build Failure Conditions step. Look for the heading Fail build if: . The first checkbox is "build process exit code is not zero". Make sure that sucker isn't checked.

  2. When you run robocopy, check the result of the call to robocopy. You can explicitly exit 0 from inside the script if robocopy works, or do something else. This is necessary if you need to fail the build upon other conditions (e.g., first exit 1 if the source folder doesn't exist, then run robocopy, then send a message if robocopy is successful).


The Team City Custom Script step fails if the last command in it fails, i.e. has a non-zero exit code. You can therefore add an extra command that always succeeds after the RoboCopy command.

For example:

robocopy ...
echo "robocopy done. this will make the build step succeed always"

Tags:

Teamcity