An extension step definition may include optional Bash shell or PowerShell scripts to be executed for the appropriate tags in step's the execution blog. These scripts define the operation of the step.
onExecute.sh/onExecute.ps1
When present in the step definition's repository directory, the onExecute.sh/onExecute.ps1 script is executed as the step's onExecute block. This should perform the primary function of the step.
The script must return a true value if the step succeeded, or false if it fails.
onExecute.sh Example
checkHealth() {
local success=true
local url=$(find_step_configuration_value "healthCheckUrl")
{
local statusCode=$(curl --silent --output /dev/stderr --write-out "%{http_code}" "$url")
} || exitCode=$?
if test $statusCode -ne 200; then
export success=false
fi
$success
}
execute_command checkHealthonSuccess.sh/onSuccess.ps1
When present in the step definition's repository directory, the onSuccess.sh/onSuccess.ps1 script is executed as part of the step's onSuccess block, in advance of user commands.
This script is executed when the onExecute script returns true.
onSuccess.sh Example
sendSuccessNotification() {
local notifyOnSuccess=$(find_step_configuration_value "notifyOnSuccess")
if [ -z "$notifyOnSuccess" ]; then
notifyOnSuccess=false
fi
if [ "$notifyOnSuccess" == "true" ]; then
echo "Health check succeeded"
fi
}
execute_command sendSuccessNotificationonFailure.sh/onFailure.ps1
When present in the step definition's repository directory, the onFailure.sh/onFailure.ps1 script is executed as part of the step's onFailure block, in advance of user commands.
This script will be executed when the onExecute script returns false.
onFailure.sh Example
sendFailNotification() {
local notifyOnFailure=$(find_step_configuration_value "notifyOnFailure")
if [ -z "$notifyOnFailure" ]; then
notifyOnFailure=false
fi
if [ "$notifyOnFailure" == "true" ]; then
echo "Health check failed"
fi
}
execute_command sendFailNotificationonComplete.sh/onComplete.ps1
When present in the step definition's repository directory, the onComplete.sh/onComplete.ps1 script is executed as part of the step's onComplete block, in advance of user commands.
For example:
onComplete.sh Example
echo "All done!"