Documentation TaskDoc JavaDoc Packages
  2. Scripting language
  3. Built-in tasks
  4. var()


The var() task can be used to access a variable with the specified name in the enclosing build target scope. This task works the same way as accessing a variable via the dereferencing operator. However it cannot be used to access expression specific local variables (e.g. foreach loop variables). In any other cases, it works the same way as dereferencing an expression.

The result of the var() task can be used on the left hand side of an assignment expression.


The following parameters are used by the task:

unnamedRequired name of the variable that is being accessed.

Task result

The reference to the variable.


# the following is the same
$num = 3
var(num) = 3

foreach $item in [1, 2] {
	# accesses the item variable, not the loop variable
	# accesses the loop variable

build(in Input) {
	# accesses the Input parameter