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:
- When you specify a group name, it works similar to the .set command.
It sets the variable value in the master record in the database, not
the copy used by the current step. The change is not seen by the adaptor
running in the current step. You cannot create new variables this
way.
- When you do not specify a group name, it works like the .bset
command. It sets the variable value in the environment of the running
job. The change is available to all the steps in the job. You can
create new variables this way.
- When you do not specify the group name and specify a temporary
variable (type="temp"), it sets up a temporary variable for the use
of the adaptor logic only. The variable does not persist after the
adaptor step runs. You can create new variables this way.
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:" />