Custom actions
The full power of the shell, spread over all your projects.
Create a custom action
You can create a custom action in 2 ways: either on the edit scenario page, or when you use the “Custom actions” menu item on the left (below the “Scenarios” menu item).
On the scenario creation page (or on the custom actions page), click the “Create new custom action” link in the right side of the screen. A modal window pops up which contains 2 different parts: on the left you’ll see a “name” field and below a black “script” field, while on the right side of the modal, you’ll see some variables together with their values.
Let’s first give the custom action a logical name, eg “Clear cache”. If this action is specific for an application or project, it might be a good idea to prefix the name with your application or project name.
In the script field, you can put bash commands. If you want to use variables in. your script, you can use the ones on the left. If you want to insert the value of a variable, click the copy/paste icon next to the variable you want to insert. Eg if you click the copy/paste icon next to the ‘currentRoot’ variable and you paste it in the script field, you’ll see that the script field now contains `{{currentRoot}}`. When your action is executed, this is replaced with the value of the variable.
Click the green “Save” button to save your action.
Executing actions without a scenario
Sometimes you just want to quickly execute a custom action without all the hassle of creating a scenario for it and adding it to the scenario.
Please click on the “Custom actions” menu item on the left. You’ll see a list of custom actions or you can create a new one using the “Create new custom action” button in the top right corner.
Click the green “Run” button next to the custom action you want to execute. When you do this, a modal window will open which asks you which stack item you want to execute the custom action on, and if you want to execute it on all instances. Click the green “Run” button to actually execute the action.
After the action has been completed, if you click in the menu on the left on “History”, you’ll see a line with the description “Run action: ……”. Using the “details” button on the left, you can see the output of the action (if any).
Important note: you can only execute scenarios or actions when your application is “running”. In case your application is not running, the “Run” button will get the color lightgreen and will be disabled.
When an action can be executed, the “Run” button will be dark green:
Reusing actions with action parameters
The real power of actions on the platform, is that you can create them as generic as you wish, and reuse them in other scenarios by using “parameters”.
First create your own custom action (see the “Create a custom actions” chapter on how to do that).
On the right side of the screen, click on the “Add default parameter”. Enter a value in the “key” field and a value in the “default value” field. For demonstration purposes, we use “hello” as key and “world” as default value. In the script screen, we type: “echo {{hello}}”. Then we save the action.
We add the newly created action to the scenario using the green + sign.
In the actions list of the scenario view, the custom action was added, and you’ll see a hash ( ‘#’ ) sign next to it. When you click on it, you’ll see that the parameter is “hello” and the value is set to “world”. If we don’t change this, this specific action will print the text “world”. If we do change the value, the task will print the new value. This way, you can re-use this task across scenarios, applications etc. while using different parameters/values.