Custom tasks

The full power of the shell, spread over all your projects.

Create a custom task

You can create a custom task in 2 ways: either on the edit scenario page, or when you use the “Custom tasks” menu item on the left (below the “Scenarios” menu item).

On the scenario creation page (or on the custom tasks page), click the “Add custom task” 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 task 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 task.

Executing tasks 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 tasks” menu item on the left. You’ll see a list of custom tasks or you can create a new one using the “Add custom task” button in the top right corner.

Click the green “Run” button next to the custom task 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 task.

After the task has been completed, if you click in the menu on the left on “History”, you’ll see a line with the description “Run task: ……”. Using the “details” button on the left, you can see the output of the task (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 a task can be executed, the “Run” button will be dark green:

Reusing tasks with task parameters

The real power of tasks 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 task (see the “Create a custom task” 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 task.

We add the newly created task to the scenario using the green + sign.

In the tasks list of the scenario, the custom task 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 task 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.