Try/Catch/Finally behaviour in tasks

Is there any way of mimicing a try/catch/finally block using build steps.

We have a build configuration which requires a server to be running. We are using the multiple build steps to


1. start the server
2. run some tests
3. stop the server

If step two fails, step three never runs, meaning that we have a stray process on the build agent. Ideally, we would like to do the following to ensure the clean-up runs even in the event of a failure:

1. start the server
try
{
   2. run some tests
}
finally
{
   3. stop the server

}

Is there any way to achieve this using build steps (or a build-cleanup step), or are we forced to use a custom script to do this logic?
1 comment
Comment actions Permalink

Hi

Please vote for TW-13682.

At the moment you'll have to put all the logic within a single step. Or take cleanup logic into separate configuration - link them by snapshot dependency and select Run build on the same agent option.

Michael

0

Please sign in to leave a comment.