Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • $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
  • $js7EpochMilli
    • The number of milliseconds since January 1st 1970 UTC.
  • $returnCode
    • The numeric exit code of the current job for which an order is executed.

Built-in Functions

  • Anchor
    function_env
    function_env
    env( 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 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 Value2021-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.


  • Anchor
    function_now
    function_now
    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 Value2021-05-03
      Expression
      now( format='yyyy-MM-dd hh:mm:ss' )
      JSON"now( format='yyyy-MM-dd hh:mm:ss' )"
      Sample Value2021-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 Value2021-05-03 09:30:42+02:00


  • Anchor
    function_scheduledorempty
    function_scheduledorempty
    scheduledOrEmpty( format='yyyy-MM-dd hh:mm:ss', timezone='Europe/Berlin' )
    • The date for which an order is scheduled.
    • The date formatting options are the same as explained with the now() function.


  • Anchor
    function_replaceall
    function_replaceall
    replaceAll( string: String, regex: String, replacement: String)
    • Similar to the Java replaceAll method.
    • Use of $ and \ in replacement: If capturing groups from the regex are used in replacement e.g. $1 then  $1 is not a variable but an identifier of replaceAll similar to the Java method replace($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 Value2021-06-27

      This example extracts the daily plan date from the build-in $js7OrderId variable, e.g. from an Order ID #2021-06-27#P0000000412-jdScheduleBusinessDays the date is extracted.


  • Anchor
    function_jobresourcevariable
    function_jobresourcevariable
    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. The function is evaluated by the Controller when adding an order. It is therefore not required to specify the requested Job Resource outside of the function. In fact the Controller reads the respective variable values from the indicated Job Resources and adds them to an Order Variable that is consider final and cannot be modified later on.
    • This function can be used with the variable declaration of a workflow only. It cannot be used with later job arguments or environment variables. When declaring the order variable with the workflow then the final data type has to be used.
    • Examples:

      Expression
      jobResourceVariable( 'database', 'db_user' )
      JSON"jobResourceVariable( 'database', 'db_user' )"
      Sample Valuescott
      Expression
      jobResourceVariable( 'database_' ++ $country, 'db_password' )
      JSON"jobResourceVariable( 'database_' ++ $country, 'db_password' )"
      Sample Valuetiger

      This example dynamically specifies the name of the Job Resource by concatenating the fixed value 'database_' and the value of the $country order variable. 

...

  • JobResource:<JobResource>:<Variable>
    • The function returns the value of the specified <Variable> from the given <JobResource>.
    • Consider the shorthand syntax that does not use brackets
    • Examples:

      Expression
      JobResource:database_uk:db_user
      JSON"JobResource:database_uk:db_user"
      Sample Valuescott
      Expression
      JobResource:database_uk:db_user orElse 'scott'
      JSON"JobResource:database_uk:db_user orElse 'scott'"
      Sample Valuescott

      This example reads the db_user variable from the database_uk Job Resource. If the variable does not exist then the default value 'scott' is used.

  • Anchor
    function_tofile
    function_tofile
    toFile( string: <Content>, string: <FileSpecification>
    • The function returns the absolute path to a temporary file that holds the value of the specified <Content> which can be a constant string or a variable of type string.
    • The file path is determined by the Agent that makes use of its JS7_AGENT_DATA/work/values directory and a temporary sub-directory.
    • The <FileSpecification>. is used to determine the file extension, for example *.xml.
    • The function can only be used with JS7 - Job Resources and JS7 - Jobs.
    • Typical use cases include a situation when longer values for job resource variables or order variables are used that would be truncated when exposed as environment variables in shell jobs. In this situation the variable's value can be written to a temporary file and the job's environment variables receives the path to the temporary file that can be processed for example with OS commands.
    • Examples:

      Expression
      toFile( 'some long string value', '*.txt' )
      JSON"toFile( 'some long string value', '*.txt' )"
      Sample Value/home/sos/agent/var_4445/work/values/0/32.txt

Further Resources

...