Versions Compared

Key

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

Table of Contents

Introduction

  • Jobs can be assigned variables from a number of sources.:
    • Shell Jobs:
    • JVM Jobs: 
      • Initialization Job Arguments populated from constant values.
      • Job Arguments populated e.g. from order variablesOrder Variables.
  • Assignment includes to consider use of JS7 - Expressions for Variables.
  • This The article explains the sources of variables and the syntax for their assignment.

Shell Jobs

Assignment of Environment Variables from Job Resources

Job Resources can be defined to hold a number of environment variables for shell jobs, e.g. in order to forward environment variables for paths and locations for Shell Jobs, for example, to forward path and location environment variables to scripts.

  • Environment variables from Job Resources are automatically available for Shell Jobs.
  • Environment variables are limited in scope to the current job. Therefore modifications to an environment variable variables by a job script are not effective beyond the scope of current job execution.
  • Environment Values for environment variables use the data type "string".

Assignment of Job Environment Variables

Shell jobs can define their an individual set of environment variables. 

  • The values of environment variables can be specified from:
  • Environment variables are limited in scope to the current job. Therefore modifications to an environment variable variables by a job script are not effective beyond the scope of current job execution.
  • Environment Values for environment variables use the data type "string". Should values from assigned variables use a different data type then the value is will be converted to "string".

JVM Jobs

Assignment of Job Arguments

Job Arguments are used by JVM Jobs on startup of the Agent.

  • The purpose of Job Arguments is to parameterize optional startup code of a JVM job that should be is run on initialization of the job and , i.e. before the job will is to be executed for orders later on.
  • Constant Only constant values only can be assigned.

Assignment of Arguments

Such arguments These Arguments are used by JVM Jobs when processing orders. 

  • The purpose of Arguments is to parameterize the processing of an order.
  • Constant values can be assigned and Order Variables.and Order Variables can be assigned.

Assignment of Base64 encoded Values

JVM jobs can hold arguments with string values of arbitrary length. 

  • If such arguments are forwarded to later shell jobs then they will be represented as environment variables that are limited in size (OS dependent).
  • If such arguments include special characters such as carriage return, newline etc. then this can break representation as an environment variable.

Users can assign JVM jobs arguments of type string with base64 encoded values:

Plain Text Valuehello world
Base64 encoded Valuebase64:aGVsbG8gd29ybGQK

The prefix base64: specifies the respective data type. JVM jobs will automatically decode bas64 encoded argument values.

You will find examples in the JS7 - How to pass variables with arbitrary length values to jobs article.

Assignment Syntax Examples

The following assignment types are available:

  • Constant string values:
    • This assignment type is used, for example, with Variable Declarations with for workflows and for with Node Arguments.
    • Example for a string value:

      GUI
      Display: var1 = value 1
    • Storage format: "var1": "value 1"
    • Input
      'value 1'
      JSON Format"var": "'value 1'"
      ExplanationSingle quoted values are considered string constants.
    • Example for an empty string value:

      GUI Input
      ""
      JSON Format"var": "\"\""
      ExplanationSingle quoted values are considered string constants.
    • Example for a quoted numeric value:

      GUI Input
      '033521'
      JSON Format"var": "'03351'"
      ExplanationSingle quoted values are considered string constants.
  • Expressions:
    • This assignment type is used with
    Expressions
    • This type is used for Environment Variables, Job Arguments and Initialization Arguments.
    • Example:


      GUI
      Display: var1 =
      Input
      $someVariable
      Storage format:
      JSON Format"var
      "var1
      ": "$someVariable"
      ExplanationSingle quoted values are considered string constants.

The following sections contain Find a number of syntax examples for assigning a variable an expression.assignment of constant values and expressions.

  • The Input representation of the examples corresponds to what a user types in the GUI for the names and values of Arguments and Environment Variables.
  • The Output representation of the examples corresponds to what is visible from the log output, e.g. using an echo command in a Shell Job.
  • The JSON representation is visible when using the "Show JSON" operation from an object's action menu.

Image Added

Examples for Constant Values

Constant values are assigned by use of using single or double quotes for an expression. No substitution of variables is performed within single quoted values.

  • Use with single quotes

    Inputvar = 'some value'
    Outputsome value
    JSON"var": "'some value'"



  • Use with double quotes

    Inputvar = "some value"
    Outputsome value

    Use with single quoted values

    JSON"var": "\"some value\""


    Double quotes have to be used to assign empty string values :

    some 'quoted' value
    Input""
    Output
    JSON"var": "\"\""
    Inputvar = 'some \'quoted\' value'
    Output



  • Use with double quoted values

    Inputvar = "some \"quoted\" value"
    Outputsome "quoted" value
    JSON"var": "\"some \\\"quoted\\\" value\""



  • Use with double quoted and single quoted values

    Inputvar = "some 'quoted' value"
    Outputsome 'quoted' value
    JSON"var": "\"some 'quoted' value\""



  • Use with $ character (not: variable) from a single quoted valuesvalue

    Inputvar = 'some $dollar value'
    Outputsome $dollar value
    JSON"var": "'some $dollar value'"



  • Use with $ character (not: variable) from a double quoted valuesvalue

    Inputvar = "some \$dollar value"
    Outputsome $dollar value
    JSON"var": "\"some \\$dollar value\""



  • Use with a built-in variable and a regular expression value

    Input^${js7OrderId}\\.order\\.js7\$
    Output^#2021-11-19#P7074917077\.order\.js7$
    JSON"var": "\"^${js7OrderId}\\\\.order\\\\.js7\\$\""



  • Use with a base64 encoded value

    Input"base64:aGVsbG8gd29ybGQK"
    Outputbase64:aGVsbG8gd29ybGQK
    JSON"var": "\"base64:aGVsbG8gd29ybGQK\""

Examples for Variable References

Assignments can reference existing variables. Variables are referenced with a leading $ and optionally with curly braces like this:

  • $var
  • ${var}

Consider Note that specifying a non-existent variable will raise a run-time error.

  • Use without quotes
    Assume var2 to hold has the value: some value

    Inputvar = $var2
    Outputsome value
    JSON"var": "$var2"



  • Use with double quotes
    Assume var2 to hold  has the value: some value

    Inputvar = "$var2"
    Outputsome value
    JSON"var": "\"$var2\""



  • Use with constant values from double quoted values
    Assume var2 to hold  has the value: second value

    Inputvar = "first value, $var2"
    Outputfirst value, second value
    JSON"var": "\"first value, $var2\""



  • Use with string concatenation from double quoted values
    Assume var2 to hold  has the value: second value

    Inputvar = "${var2}first value"
    Outputsecond valuefirst value
    JSON"var": "\"${var2}first value\""



  • Use with constant values and single quoted values
    Assume var2 to hold  has the value: second value

    Inputvar = "first, '$var2'"
    Outputfirst, 'second value'
    JSON"var": "\"first, '$var2'\""



  • If a variable name includes dots, then the name has to be specified within curly braces and has to be quoted with backticks.
    Any characters can be used within backticks, except for backticks themselves.

    Input${`mail.smtp.host`}
    Outputmail.sos-berlin.com
    JSON"var": "${`mail.smtp.host`}"