Create a Jython Script task

A Jython Script task contains a Jython script that is executed on the XL Release server. This is an automated task that completes when the script finishes successfully.

The inline script editor is used to enter script. Type or paste a Jython script into the Script field of the Jython script task details. To enlarge the script editor, click enlarge editor. Pressing this button again will minimize the editor.

Jython Script Task Details

XL Release supports Jython 2.7. Jython is the Java implementation of Python. This means that you have access to standard Python as well as the Java libraries included in Java 8.

Note: The output of the Jython Script task is in markdown format. For more information, refer to Using Markdown in XL Release.

You can access and modify release variables in your scripts using the dictionary named releaseVariables. This sample script shows how to access and modify a variable:

releaseVariables['xldeployPackage'] = 'XL Release'

In a similar way, you can modify global variables using the dictionary named globalVariables.

If you want to update global variables, the Run automated tasks as user variable must be set to a user that has the Edit global variables permission.

To set this variable:

  1. In the top navigation bar, click Releases.
  2. Click a release.
  3. In the Show dropdown, click properties.
  4. In the Run automated tasks as user field, set a user.
  5. Click Save.

In the release flow editor, Jython Script tasks have a gray border.

Security and Jython Script tasks

When a Jython Script task becomes active, the script is executed in a sandbox environment on the XL Release server. This means that the script has very restricted permissions. By default, access to the file system, network, and non API related classes is not allowed.

To remove these restrictions, add a script.policy file to the XL_RELEASE_SERVER_HOME/conf directory. This is a standard Java Security Policy file that contains the permissions that a script should have.

To enable the use of additional Java packages or classes in the script, use the following XL Release specific RuntimePermission:

    permission "*";
    permission "";

To allow the use of a restricted built-in Jython module in the script, please remove the module from the list of restricted modules in the XL_RELEASE_SERVER_HOME/conf/xl-release.conf file: = ["importlib", "imp", "tempfile", "linecache", "shutil", "os",
                                                              "getpass", "platform", "threading", "thread", "subprocess", "webbrowser", "cmd",
                                                              "pdb", "bdb", "gc", "user", "code", "codeop", "zipimport", "pkgutil", "modulefinder",
                                                              "runpy", "distutils", "compiler", "posix", "pwd", "grp", "posixfile", "commands"]

Note: Although we do not advise doing so, it is possible to disable the sandbox environment of the script task by updating the XL_RELEASE_SERVER_HOME/conf/xl-release.conf file: = false

By default, all password properties for release, phase, and task are encrypted in script task context. It is possible to get decrypted password properties by updating the XL_RELEASE_SERVER_HOME/conf/xl-release.conf file: = true

This is a deprecated feature and it will be removed in future releases.

You must restart the XL Release server after creating or changing the XL_RELEASE_SERVER_HOME/conf/script.policy or the XL_RELEASE_SERVER_HOME/conf/xl-release.conf file.

Sample scripts

This sample script shows how to download a file from a web site and save it locally:

import httplib
url = ''
file = '/tmp/xebialabs.html'
xl = httplib.HTTPConnection(url)
xl.request('GET', '/')
response = xl.getresponse()
myFile = open(file, 'w')
print "Save %s to %s" % (url, file)

This example grants access to the network using Python httplib and read/write access to the /tmp directory on the XL Release server:

grant {
    // Network access
    permission  java.lang.RuntimePermission "";
    permission "*", "connect, resolve";

    // File access
    permission "/tmp/*", "read, write";
    permission java.util.PropertyPermission "line.separator", "read";