Goto activity in TFS workflow?
-
Friday, April 27, 2012 8:26 PM
Is there a Goto activity in TFS build workflow that execute "Goto" functionality?
If I'm at Activity A, is there a way I can make the build "goto" Activity C and D but skip B?
Thanks
All Replies
-
Sunday, April 29, 2012 10:12 AMnope. You'll need to set a variable and give it a logical name (such as SkipActivityB) and set it true from activity A. You can then use an IF block.
My blog: blog.jessehouwing.nl
-
Sunday, April 29, 2012 3:33 PM
It's a simple situation.
Say if I have a real situation like:
Sequence 1
--> Activity A
---> Activity B
----> Sequence 1.1
--> Activity C
-- >Activity D
Activity E
For some conditions, after finishing A or C, I want to it skips the rest and "goto" E.
They're all our custom activity and we have fully control them. The only way I'm thinking is using Try/catch and throw from A and C if some conditions have raised. Then make a "catch" surround E.
Anyone see other ways to do "goto" in the workflow?
Thx
- Edited by garynguyen Sunday, April 29, 2012 3:34 PM
-
Sunday, April 29, 2012 4:06 PM
Don't use exceptions for flow control.
Just make sure the outcome of each activity is part of its output parameters. Store the output in a variable of your build template and use if/then blocks to execute the other activities based on the values of these variables.
My blog: blog.jessehouwing.nl
-
Monday, April 30, 2012 1:16 AMHi Jesse, thanks very much for your answer, here is another situation:
Say if I have this scenarios:
Sequence 1
--> Activity A
---> Activity B
---> Default Try block to compile project using MSBUILD
----> Sequence 1.1
--> Activity C
-- >Activity D
Activity E
If the sequence above executed and the .net project fails to compile at Try lock using MSBUILD, it sets the build compilation status to fail then the build stop right away because of the "Rethrow" in the DefaultTemplate.xaml.
It never calls to execute my custom activity E.
Beside making another Try/Catch block wrap around it, is there other way?
Thx -
Monday, April 30, 2012 9:46 AM
You could remove the rethrow, and set a custom variable in the catch block and derive your logic from there.
In this case a try/catch of your own would make sense though, as it's an exceptional flow.
My blog: blog.jessehouwing.nl
-
Monday, April 30, 2012 4:56 PM
Thanks Jesse, I'm thinking about removing the rethrow before but here is the point: If a project fails to compile, i prefer using the rethrow so the workflow will not continue (to save time), instead the activities in Catch block should be called in this situahxtion.
In general, going back to my first question, i guess the answer is NO? there is no way to make "goto" in workflow?
Thx
- Edited by garynguyen Monday, April 30, 2012 4:57 PM
-
Monday, April 30, 2012 6:43 PM
You could write your own "goto"-like functionality using a new NativeActivity-derived class, but it would not be easy to implement correctly given the nature of the activity scheduling engine.
Patrick
- Marked As Answer by garynguyen Monday, April 30, 2012 9:06 PM
-
Monday, April 30, 2012 9:06 PM
It's a simple answer of NO, as out of the box from MS.
Thanks Patrick, I'll mark it as an answer.

