Enable / Disable Actions with a script

Hello

I've got a question about enable / disable different actions.

I've a list with actions.

I build a project twice a day. A daily build an a nightly build. The daily build don't use as much actions as the nightly build does.

My question is now, can I use the same action list for both? (daily and nightly build) When I run a daily build can I disable all the action which I don't need?  (Maybe with a script or something like that?)

Thanks a lot!

I hope you understand what I meaning ;-)

Regards

Christof

Hi Christof,

You can skip an action at runtime. There are three ways to do this:

1) Use an Execute Condition. If you go to the “Runtime” tab of an action, then there is a section at the bottom called Execute Condition. The Execute Condition is a small piece of script which must evaluate to “True”, or the action will be skipped.

Say you had a Project Variable called IsNightlyBuild, which is set from the scheduled nightly build with the /V option. The Execute Condition could be simply “IsNightlyBuild”.


2) Use the BeforeAction script event on an action. This script event has a pass-by-reference parameter called SkipAction which you can set to True in order to skip the action.


3) Use If/Then logic. If you need to skip multiple actions, it can be a good idea to group them together as the child of an If/Then action, and use the If/Then logic to determine whether or not to run them. This can make it easier to see the logical and functional structure of your build process.


Please let me know if you’d like an in-depth walkthrough on any of these techniques.

Regards,


Angus

Hi Angus

Thanks for your repy!

Would your first suggestion work with more than 2 build options I have about 8 build options

What would you prefer? For each build option a separate action list? Or one of the solution which you told me?

Thanks a lot!

Regards,

Christof

Hi Christof,

So you mean that there are 8 different types of builds you could be running?

It really depends on how different they are. If there are lots of major differences, separate action lists could be an option. If there are only minor differences, you might want to parse the build type and set some other variables, for example using the Switch/Case actions

Switch(BuildType)
Case NightlyBuld:
Set Variable RebuildAll = True
Set Variable RunTests = True

Case DailyBuild
Set Variable RebuildAll = False
Set Variable RunTests = True

… etc, etc.

Or there are numerous other ways you could do it.

Regards,

Angus

Thanks for your help!

I'll try the different proposals.

Regards

Christof