Skip to main content
Version: Early Access

Set a Precondition on a Task

The execution flow can be controlled by setting a precondition on a task.

A precondition is an if statement for tasks, written in Jython script code. If the precondition evaluates to True, the task is started. If the precondition evaluates to False, the task is skipped. If an exception is raised or a compilation error occurs when Release is evaluating the precondition script, the task is failed. The script can be fixed and execute with retry the task.

Manual Task With Precondition

There are two ways to writing preconditions.

Boolean expression

A Boolean expression is restricted to single statement script. For example:

releaseVariables['jobStatus'] == 'Success'

The task will only be started if the variable jobStatus is equal to 'Success'.

Multi-line script

If a more complicated script is required, the result variable should be set. For example:

if releaseVariables['OS'] == 'Linux' and releaseVariables['pingResult'] == '0':
result = True
else:
result = False

Disabling preconditions

Precondition can be disabled on certain task types. For example, to disable a precondition on parallel groups, file synthetic.xml should be modified as follows:

<type-modification type="xlrelease.ParallelGroup">
<property name="preconditionEnabled" kind="boolean" required="true" default="false" hidden="true"
description="Whether preconditions should be enabled"/>
</type-modification>