Page History
...
Variables can be retrieved using the function
variable( NAMEstring: <variable>, label=LABEL<label>, job=JOB<job>, default=DEFAULT <default> )
NAME
<variable>
is a string expression for the name of the variable.label=LABEL<label>
(optional) is the label of an instruction for which the variable is recalled. Consider that the label is not quoted. Example:label=A
.job=JOB<job>
(optional) is the name of a job for which the variable is recalled. Consider that the job name is not quoted. Example:job=MYJOB
.default=DEFAULT<default>
(optional) specifies a the default value should the variable not exist.
...
Expression |
|
---|---|
JSON | "variable( \"my_var\", job=\"my_job\" )" |
Comment | The value of the variable my_var is returned as available with the job my_job in a workflow. If the variable is unknown then the function fails. |
...
$js7JobName
- The name of the current job for which an order is executed.
$js7JobExecutionCount
- A counter for the number of times that the same job node is executed within a workflow, e.g. if used with the JS7 - Retry Instruction
$epochMilli
- The number of milliseconds since January 1st 1970 UTC.
$returnCode
- The numeric exit code of the current job for which an order is executed.
Build-in Functions
env( "environment-variable", "default" string: <environment-variable>, string: <default> )
- The function reads the value of an existing OS environment variable. The name has to be specified in correct uppercase/lowercase spelling.
- If the environment variable does not exist then an error is raised and the Order fails. Alternatively a an optional default value can be specified.
Examples:
Expression env( ('JS7_AGENT_CONFIG_DIR')
JSON "env( 'JS7_AGENT_CONFIG_DIR' )"
Sample Value /var/sos-berlin.com/js7/agent/var_4445/config
Expression env( 'JAVA_HOME', '/usr/lib/jvm/java-1.8-openjdk' )
JSON "env( 'JAVA_HOME', '/usr/lib/jvm/java-1.8-openjdk' )"
Sample Value /usr/lib/jvm/java-1.8-openjdk
Expression env( 'HOSTNAME', env( 'COMPUTERNAME' ) )
JSON "env( 'HOSTNAME', env( 'COMPUTERNAME' ) )"
Sample Value 2021-05-03 07:30:42 This example assumes the
$HOSTNAME
environment variable to be available for Agents running on Unix or the%COMPUTERNAME%
environment variable to be available for Agents with Windows.
now( format='yyyy-MM-dd hh:mm:ss', timezone='Europe/Berlin' )
- The job start date. This date can be formatted using Java date qualifiers. Optionally a time zone can be specified, by default the UTC time zone is used.
Examples:
Expression now( format='yyyy-MM-dd' )
JSON "now( format='yyyy-MM-dd' )"
Sample Value 2021-05-03 Expression now( format='yyyy-MM-dd hh:mm:ss' )
JSON "now( format='yyyy-MM-dd hh:mm:ss' )"
Sample Value 2021-05-03 07:30:42 Expression now( format='yyyy-MM-dd hh:mm:ssZ', timezone="Europe/Berlin" )
JSON "now( format='yyyy-MM-dd hh:mm:ssZ', timezone=\"Europe/Berlin\" )"
Sample Value 2021-05-03 09:30:42+02:00
scheduledOrEmpty( format='yyyy-MM-dd hh:mm:ss', timezone='Europe/Berlin' )
- The date for which an orders order is scheduled.
- The date formatting options are the same as explained with the
now()
function.
replaceAll( string: String, regex: String, replacement: String)
- Similar to the Java replaceAll method.
- Use of on
$
und\
inreplacement
: If capturing groups from theregex
are used inreplacement
e.g.$1
, then$1
is not a variable but an identifier ofreplaceAll
similar to the Java methodreplace($myString, 'x', '-->$1<--')
.replacement
. Examples:
Expression replaceAll( $js7OrderId, '^#([0-9]{4}-[0-9]{2}-[0-9]{2})#.*$', '$1' )
JSON "replaceAll( $js7OrderId, '^#([0-9]{4}-[0-9]{2}-[0-9]{2})#.*$', '$1')"
Sample Value 2021-06-27
Analog zu Javas (replaceAll)[https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#replaceAll-java.lang.String-java.lang.String-].
Zur Angabe von
$
und\
inreplacement
: Wenn Gruppen ausregex
inreplacement
verwendet werden, also etwa$1
, dann ist$1
keine Variable der Ausdruckssprache, sondern vonreplaceAll
, wie inreplace($myString, 'x', '-->$1<--')
.replacement
ist also ein String in Apostrophen.replace($myString, 'x', "-->$1<--")
dagegen würde
$1
der Ausdruckssprache verwenden und nicht das gewünscht Ergebnis liefern (wahrscheinlich wird es scheitern).
jobResourceVariable( string: <JobResource>, string: <Variable> )
- The function provides access to JS7 - Job Resources: it reads from the Job Resource specified with the first argument and returns the value of the Job Resource variable specified with the second argument.
Examples:
Expression jobResourceVariable( 'database', 'db_user' )
JSON "jobResourceVariable( 'database', 'db_user' )"
Sample Value scott Expression jobResourceVariable( 'database_' ++ $country, 'db_user' )
JSON "jobResourceVariable( 'database_' ++ $country, 'db_user' )"
Sample Value tiger
Further Resources
...