setenv

Use the <setenv> element to initialize environment variable values within <interface> or <match> elements. The <setenv> element does not contain other elements.

The element can be used in three different ways:

Attributes:

condition
Optional, in the form condition="function". The value of function is an expression that evaluates to true or false. If it evaluates to true, the command is run. If it evaluates to false, it is not run. See Condition functions.
eval
Optional. Set to True or False. If true, the adaptor attempts to evaluate the value attribute expression and store the results.
group
Optional. It specifies the Build Forge environment that the variable is defined in. When you specify a environment name, you must refer to an existing variable within the specified environment.

If you specify [ADAPTOR] as the value, then the value is set at run time. It is set to the environment of the step or adaptor link that calls the adaptor.

Build Forge allows variables of the same name in multiple environments. The precedence of environment inheritance and environment inclusion can affect how to determine the value to assign to a variable at run time.

name
Required. It specifies the name of the variable to set. The value can be a variable. In that case, the variable name is not set until run time.
type
Optional. It specifies the method of setting the variable. It takes one of the following values:
  • append text: place the specified value after any existing value. If the optional text is specified, that text is placed between the values.
  • once: the variable should be set only if it is not already set.
  • prepend text: place the value before any existing value.
  • temp: the variable should be set only in the context of the adaptor. If the optional text is specified, that text is placed between the values. See examples below.
value
Required. It is the value to set in the variable. It can be an expression to be evaluated if the eval attribute is also specified. The result of the evaluation is stored as the value.

Examples:

The following example evaluates the expression in the value attribute and stores the result in the variable LAST_VER. It is set to the greater of $LAST_VER or the value in the $1 variable.

<setenv group="Adaptor" name="LAST_VER" 
   value="$LAST_VER>$1?$LAST_VER:$1" eval="true" />
The following example inserts a newline character (\n) before appending data to the Changes variable:
<setenv name="Changes" value="$4 - $1 - $6" type="temp append\n" />

The following example inserts a colon after the value it prepends to variable INFOPATH:

<setenv name="INFOPATH" value="/usr/local" type="temp prepend:" />

Feedback