Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing a TFS2010 workflow build to FAIL instead of PARTIALLY SUCCEED

Tags:

build

workflow

I currently have a custom workflow activity to run an external process, after the solution has been compiled successfully, that returns an ExitCode <> 0 if the external process has failed. Once I know that the process has failed, I want to set the build status to FAIL (as you would see if code has not compiled) so I have added a SetBuildProperties activity which will set the Status property to BuildStatus.Failed but this only seems to result in giving a Partially Succeeded build when the build is finished.

I have tried setting the build's compilation status to failed inside my custom activity which does result in a Failed build, but I don't really want to have to do that as it is misleading when the solution has compiled.

Can anyone tell me how I can force a build to fail?? (preferably without having to set the compilation status to failed!)

Thanks

like image 870
Vermin Avatar asked Jun 09 '11 09:06

Vermin


2 Answers

What happened here is that when the build finishes, the workflow manager will overwrite the build status to a value that depends on the combination of statuses of the build process. In your case, the CompilationStatus is Succeeded, but there is a custom activity failure (you set the BuildStatus to Failed), so the overall status would be PartiallySucceeded.

The only workaround here is to set the CompilationStatus to either Failed or Unknown, then the build status will be Failed.

I haven't tried setting the CompilationStatus to Unknown though. But if it can be done, you can later go back and change it to Passed. Just a way to distinguish with the real failed compilation builds.

Not a great workaround, I know :(

UPDATE: Using SetBuildProperties activity to set the build status to Failed and I was able to fail the build even though the compilation succeeded.

like image 163
Duat Le Avatar answered Nov 20 '22 15:11

Duat Le


In TFS 2013, using a customized build template you can just set the the build status to Failed while leaving the CompilationStatus and TestStatus to it's rightful values. You have to do it after the test run though, otherwise it gets updated back. Use the SetBuildProperties activity and set the "Status" property.

like image 44
Jessica Avatar answered Nov 20 '22 13:11

Jessica