开发者

Forcing a TFS2010 workflow build to FAIL instead of PARTIALLY SUCCEED

开发者 https://www.devze.com 2023-03-11 06:45 出处:网络
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 k

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 wit开发者_开发问答hout having to set the compilation status to failed!)

Thanks


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号