Detect why the build stopped

Is there a way to detect that the build was stopped manually by a user,as opposed to stopping because of a build error? I’d like todetect a manual stop and prevent the build failure notification emailfrom being sent. I suppose I could search the log file, but I waswondering if there’s a better way.

Hi Ed,

If you stop the build manually, I’m pretty sure that any try/catch/finally actions will be ignored, whereas if an action fails, then the actions in the try/catch/finally will run. So, if you put your send email actions within the catch section (or in the OnFailure action list) then this should work as you need it to.

hth.
.t8


(Ed, I think you’ve spelt your email address incorrectly, because the automated email from the forum is bouncing).

I have some send email actions in the OnFailure Script.

When I press the Terminate Build, it always executes the OnFailure
Script.

I also have wanted to have away to optionally not do that. But Its been low on my priority list so I have not looked or asked.

Ah, yes… if you terminate while inside a try/catch/finally/end block then the build stops immediately, whereas if you terminate an action that is not inside a try block, it will run any actions in the OnFailure.

.t8

The OnFailure does not get executed if you select the “Stop after current action” instead of “terminate”. I personally never use the terminate button as I won’t know what state things are in if I kill a process in the middle. My OnFailure section has actions that send out emails and update status, so the “Stop” works best for me as I don’t want failure messages going out when there was no actual failure. :wink:

As for a “why” the build stopped, we actually have a string variable set in each build step by the beforescript. This gets sent out in the emails in the event of an actual failure.

… if you want to be really tricky, you can press Stop and then press the red Terminate if things don’t stop in time. This will stop the build without running Finally/OnFailure, as well.