'Script step' is found in the 'Common' category of workflow nodes.
The script node is used to run generic busby scripts. In general it is expected that these scripts should be short-running - seconds not minutes. However, if this is not the case consider using the Polling script node, or waiting for an event such as the File wait step, or the Wait for message step. The output of a script node is determined by the exit code given in the busby.exit
call.
Typically, a script step might preform a pass/fail test; passing the test sets a result code of '0' (zero) and failing the test sets a result code of '1'. Depending on the result code, the job will take a different path through the rest of the workflow.
Detailed notes on the configuration editor can be found here
The following is a simple example of the sort of logic that can go into a script.
if (_.startsWith(root.job.internalRef, 'ABC') {
busby.exit(0);
} else {
busby.exit(1);
}
This script was included in the workflow diagram in the following way.
The result codes were set on the script step to add two valid result codes, and one 'killed' result code. The result code values of 0 and 1, need to match the value passed to the busby.exit
function.
It is possible to add extra result codes, and these will make new tags appear on the script step node, which can be connected to other nodes. An exit tag of a script step is only allowed to go to one other node. If no exit tag is defined and busby.exit is called for that result code, the job will remain in the current state.
Script steps readily support the following scripting languages:
If you are used to using 'console.log' style statements to monitor what is going on in a script you will need to get used to Busby's alternative 'busby.log'.
So, a common task written as a script step (using TypeScript) in Busby might look like this:
busby.log("Hello, World!");
busby.exit(0);
One of the advantages of scritping in TypeScript in Busby is the extensive typing and hinting available.
Details of the general scripting process in busby can found here.
Previous: Polling script step || Next: Service poller
Index of: Workflow Nodes
Back to: Configuration Editor