Scoping

Variables assigned outside of any block are global and visible to all blocks. A variable assigned within a block is visible only within that block.

Inside a block, you can assign a variable as a global variable, which is visible within other related blocks. Use the following syntax:

global a = 5.2

The following table describes what blocks are related with respect to scope:

Global variable set in

Effective in

outside of the lifecycle blocks

all blocks

the prejob block

all blocks

the pretask block

pretask, task and posttask

the task block

task and posttask

the posttask and postjob blocks

that block

Note that assigning a variable with the same name as a previously defined global variable does not change the value of the global variable. Instead, it creates a new local variable in the block, and that local variable has local scope and does not change the value of the global variable.