Skip to end of metadata
Go to start of metadata

Introduction

  • Jobs can be assigned variables from a number of sources.
    • Shell Jobs:
    • JVM Jobs: 
      • Job Arguments populated from constant values
      • Arguments populated e.g. from Order Variables
  • Assignment includes to consider use of JS7 - Expressions for Variables.
  • The article explains the sources of variables and the syntax for 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. to forward environment variables for paths and locations 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 environment variables by a job script are not effective beyond the scope of current job execution.
  • Values for environment variables use the data type "string".

Assignment of Job Environment Variables

Shell jobs can define 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 environment variables by a job script are not effective beyond the scope of current job execution.
  • Values for environment variables use the data type "string". Should values from assigned variables use a different data type then the value is 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 job that is run on initialization of the job, i.e. before the job will be executed for orders later on.
  • Constant values only can be assigned.

Assignment of Arguments

Such Arguments are used by JVM Jobs when processing orders. 

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

Assignment Syntax Examples

The following assignment types are available:

  • Constant string values
    • This assignment type is e.g. used with Variable Declarations for workflows and with Node Arguments
    • Example:
      • GUI input: "value 1"
      • JSON format: "var1": "\"value 1\""
  • Expressions
    • This assignment type is used with Environment Variables, Job Arguments and Initialization Arguments
    • Example:
      • GUI input: $someVariable
      • JSON format: "var1": "$someVariable"

From the following chapters find a number of syntax examples for 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.

Examples for Constant Values

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

  • Use with single quotes

    Input'some value'
    Outputsome value
    JSON"var": "'some value'"



  • Use with double quotes

    Input"some value"
    Outputsome value
    JSON"var": "\"some value\""
  • Use with double quoted values

    Input"some \"quoted\" value"
    Outputsome "quoted" value
    JSON"var": "\"some \\\"quoted\\\" value\""



  • Use with double quoted and single quoted values

    Input"some 'quoted' value"
    Outputsome 'quoted' value
    JSON"var": "\"some 'quoted' value\""



  • Use with $ character from single quoted values

    Input'some $dollar value'
    Outputsome $dollar value
    JSON"var": "'some $dollar value'"



  • Use with $ character from double quoted values

    Input"some \$dollar value"
    Outputsome $dollar value
    JSON"var": "\"some \\$dollar value\""

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 that specifying a non-existent variable will raise a run-time error.

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

    Input$var2
    Outputsome value
    JSON"var": "$var"



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

    Input"$var2"
    Outputsome value
    JSON"var": "\"$var\""



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

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



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

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



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

    Input"first, '$var2'"
    Outputfirst, 'second value'
    JSON"var": "\"first, '$var'\""
  • For variable names that include dots the name has to be specified within curly braces and has to be quoted with backticks.
    Within backticks any characters can be used expect for a backtick.

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




  • No labels
Write a comment…