Page History
Table of Contents |
---|
Purpose
- The If Instruction is used for conditional processing in a workflow. It allows to check return codes and return values of previous jobs and it can be used to evaluate any order variables.
- The If Instructions optionally allows to use an "Else" branch if the condition evaluates to
false
. - An If Instruction evaluates an expression that includes order variables and that results in a
true
/false
value. The following basic use cases are suggested:- check the return code (exit code) of a previous job to decide which jobs or instructions to continue with,
- check the return value (variables returned by a previous job) to decide about further processing,
- check any order variables to determine the next instructions to process.
- The If Instruction does not modify an order's state, however, if an If Instruction fails due to an error in the expression or syntax then the order is considered broken.
...
- The If Instruction knows of two binary operations, which are "and" (conjunction) and "or" (disjunction) with the syntactical notation syntax
&&
and||
.The Possible operations satisfy correspond to the following table table:
x y x && y x || y false false false false true false false true false true false true true true true true - Round brackets should be used to group multiple expressions and to control the order of evaluation.
- Conjunction beats disjunction if no grouping is used, i.e.
-
x && y || z
is the same as(x && y) || z
-
x || y && z
is the same asx || (y && z)
-
- Both operations using the basic elements
true
|,false
cover a number of algebraic laws such as associativity, commutativity and distributivity, for more details see Wikipedia.
...
- The If Instruction knows a single unary operation. This is "not" (negation) for which the notation syntax is
!
.The unary operation results in the following table:
x !x false true true false - A negation can be used for a single expression or for a group of expressions which are enclosed by round brackets.
- The unary operation satisfies particularly De Morgan's law. i.e.:
!x && !y
=!(x || y)
!x || !y
=!(x && y)
...
- The predicate supports to check the value of job arguments and of order variables.
- Variables support the following data types: string, number, boolean.
- While an order passes a workflow any job can add or modify order variables.
- A number of syntactical notations for variables are supported that give acccess provide access to
- the current value of a variable (maybe modified by a previous job),
- the value that was returned by a specific JS7 - Job Instruction,
- the original value of the variable as carried by the order.
If a predicate makes use of a variable that does not exists then the order stops with a FAILED state except that a default value has been specified for the variable.
...
- The following syntax can be used for to access the current value of a variable:
$varName
${varName}
variable("varName")
orvariable('varName')
variable(key = "varName")
orvariable(key = 'varName')
- To avoid that an order stops because of a non-existent variable, a default value can be specified with the following syntax:
variable("varName", default = "aString")
orvariable('varName', default = 'aString')
variable(key = "varName", default = "aString")
orvariable(key = 'varName', default = 'aString')
- The default Default values use one of the supported data types: string, number, boolean.
- If the variable name is used with the
key
attribute then the order of appearance ofkey
attribute anddefault
attributes attribute is arbitrary, i.e.variable(default = "aString", key = "varName")
is possible too. - If the variable name is used without the
key
attribute then the variable name has to be used as the first argument ofvariable(...)
.
...
- The following syntax can be used to access the original value of an order variable:
argument("varName")
orargument
('varName')
argument(key = "varName")
orargument
(key = 'varName')
- An
argument
can specify a default value too (see previous chapter).
Value of a variable from a specific Job Instruction
...
Overview
Content Tools