teamcity

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


I have a command line 'custom script' build step involving robocopy. Unfortunately when robocopy is successful, it returns exit code 1 instead of the more common exit code 0. When it does this, it fails my teamcity build configuration.

How can I tell teamcity to fail the build if the exit code != 1 for this build step only? Can this be done? What about editing project-config.xml somehow?


Solution

  • 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).