Condition functions are used in the Condition step property
and in the condition attribute in adaptor XML elements.
- For steps using the Condition property: If the following functions
are used at the beginning of the Condition field, they are evaluated by
the engine and no information is sent to the selected server unless
the condition evaluates to true. The step is run on the selected server
if the condition evaluates to true.
Important: - Do not attempt to use the functions on variables that are set
in the shell environment of the server resource. The evaluation takes
place on the Build Forge engine, so they work only on variables that
are defined in the Build Forge environment for the step.
- Do not use operator characters in strings that are evaulated.
Operator characters are =, <, >, !
- For adaptor templates: the following functions are available to
use in adaptor XML elements that have a condition attribute. They
are used to specify how the adaptor runs. Important: the condition
function must be in double quotes in the condition attribute: condition="condition_function".
The following functions are available:
- true(expression)
- Returns true if expression is true.
- false(expression)
- Returns true if the expression is false.
- contains(a,b)
- Returns true if string a contains string b. The a and b parameters
can be literal strings or variables. Literal strings should not be
quoted. If literal strings are quoted, the quotes become part of the
string that is evaluated.
Note: Before Rational Build Forge version
7.1.2, this function returned true if string a was in string b.
- hastext(var)
- Returns true if the variable is not empty. Var is a variable
set within Build Forge.
- isempty(var)
- Returns true if the variable is empty. Var is a variable
set within Build Forge.
- a eq b
- Returns true if a is equal to b. The a and b parameters
can be variables set within Build Forge or literal values. Character
and numeric types can be used. Use a space between the parameters
and the operator.
- a ne b
- Returns true if a is not equal to b. The a and b parameters
can be variables set within Build Forge or literal values. Character
and numeric types can be used. Character and numeric types can be
used. Use a space between the parameters and the operator.
- a contains b
- Returns true if string b is found in string a. Literal
strings should not be quoted. If literal strings are quoted, the quotes
become part of the string that is evaluated. Character and numeric
types can be used. Use a space between the parameters and the operator.
Expressions in functions
The
expression parameter
of the true() and false() functions can use the following operators:
- a==b
- Tests equality. Parameters can be strings or numbers. Parameters
can be literals or variables defined in Build Forge.
- a eq b
- Tests equality. Parameters can be strings or numbers. Parameters
can be literals or variables defined in Build Forge. Use a space between
the parameters and the operator.
- a!=b
- Tests inequality. Parameters can be strings or numbers. Parameters
can be literals or variables defined in Build Forge.
- a ne b
- Tests inequality. Parameters can be strings or numbers. Parameters
can be literals or variables defined in Build Forge. Use a space between
the parameters and the operator.
- a>b
- Tests that a is greater than b. Parameters must
be numeric. Parameters can be literals or variables defined in
Build Forge. Literals can use arithmetic operators, for example 2+2.
- a<b
- Tests that a is not greater than b. Parameters
must be numeric. Parameters can be literals or variables defined
in Build Forge. Literals can use arithmetic operators, for example
2+2.
- a>=b
- Tests that a is greater than or equal to b. Parameters
must be numeric. Parameters can be literals or variables defined
in Build Forge. Literals can use arithmetic operators, for example
2+2.
- a<=b
- Tests that a is not greater than or equal to b. Parameters
must be numeric. Parameters can be literals or variables defined
in Build Forge. Literals can use arithmetic operators, for example
2+2.
- a contains b
- Tests that string b is found in string a. Parameters
can be literals or variables defined in Build Forge. Literal strings
should not be quoted.
Examples of Condition functions
In the examples
in the table below, variables are set as follows:
- $AVAL contains the value String.
- $BVAL contains the value 3.
Condition |
Evaluates To |
Notes |
A String contains $AVAL |
TRUE |
String comparison |
A String contains "String" |
FALSE |
The quotes around String become part of the comparison. |
true(A String contains $AVAL) |
TRUE |
String comparison |
$AVAL contains String |
TRUE |
String comparison |
$AVAL contains "String" |
FALSE |
The quotes around String become part of the comparison. |
contains(A String,$AVAL) |
TRUE |
String comparison |
true(A String contains "$AVAL") |
FALSE |
The quotes around $AVAL become part of the comparison; "A
String" does not have a quotes around the "String" part. |
A String != $AVAL |
TRUE |
String comparison |
A String ne $AVAL |
TRUE |
String comparison |
false("Not Here" contains $AVAL) |
TRUE |
Test string comparison |
true(2+1 == $BVAL) |
TRUE |
Numeric expression for equality |
false(2+2 < $BVAL) |
TRUE |
Numeric expression for inequality |
$AVAL eq $AVAL |
TRUE |
Test string comparison |
true($AVAL ne Linus) |
TRUE |
Test string comparison |
true($BVAL > 2+2) |
FALSE |
(3 > 2+2) is not true |
contains(Not Here, $AVAL) |
FALSE |
Test string comparison |