How to Fail a Commandline Build Step

I have a series of build steps all of which I want skipped if any previous step fails. In my template's Build Failure Conditions, I've checked all conditions. A few of the build steps are commandline buildrunner steps. In these build steps, the scripts inject TeamCity Service Messages to indicate errors and warnings. The errors and warnings show up in the TeamCity Build Log as expected, but I note the error service message does not trip a Build Failure Condition. For most of these script steps, I can set a non-zero exit code to fail the step and prevent subsequent steps from executing.

One commandline build step script can only return zero. To make a long story short, this script is executing Eclipse from the commandline, capturing the output and parsing it for error and warnings and injecting the appropriate error or warning service message.Unfortunately, the Eclipse executable itself can throw up error dialogs as it shuts down due to Eclipse/plugin incompatibility, so I suppress the dialogs and since I can't tell who made the error (captured code compilation error or Eclipse), I smother it and always return zero.

The question is: How do I force TeamCity to see this commandline runner build step as failed? Since I always return zero, subsequent step continue to execute.
As I said, it doesn't appear that the error service message marks a build step as failed.
I've also tried to inject build status service messages with status FAILURE. This reports nicely, but does not trip a Build Failure Condition.

How do I prevent subsequent build steps from building if the script detects compilation errors?

Any help would be appreciated.


1 comment
Comment actions Permalink


Better late then never...

In TeamCity 8.0 there is an "If all previous steps finished successfully" option of "Execute step" which does not run the step if the build is displaying as "failing" at the time.


Please sign in to leave a comment.