How to use a multi-line script in an XL Release Task's precondition?


Shashank Srivastava -


Sometimes you need to start a task in XL Release that depends on multiple conditions from another task using a multi-line script.


XL Release

Steps to Perform

Suppose you have 2 Script tasks. First Script task pings a remote server & checks if there is any packet loss. It stores the result in a variable called ${pingResult}. Second Script task checks the OS of remote server & stores the result in a variable called ${pingResult}. Now you have another Phase & a Notification task there. This task sends an e-mail with some details. Now, you want this task to run (send an e-mail) only when OS of remote server is Linux & there is no packet loss. So, you set a precondition in this Notification task with 2 conditional statements like below.

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

Now your Notification task will only run when both the conditions are met. Please find attached the sample Template based on above scenario. Of-course, its a very simple use-case. It can be modified in any manner depending upon your needs.


Since its a Jython script, pay attention to the indentation.

Additional Information

More information can be had from the below link.

xl-release, how-to, precondition, task