Skip to end of metadata
Go to start of metadata

Introduction

  • Order Variables can be used to parameterize workflows and jobs.
  • Order Variables are declared with a Workflow.

Feature Video

This video explains how to parameterize workflows and pass variables to jobs in a workflow.

Declaring Variables

The JS7 - Workflow Editor offers to declare variable. Clicking into the workflow editor panel with display the workflow properties that offer to add variables:

Explanations:

  • Order variables are declared by specifying a name and data type.
    • If no default value is added then the order variable is mandatory, i.e. any orders have to specify a value for the variable.
    • If a default value is added then the order variable is optional, i.e. orders can specify a value and otherwise the default value is used.
    • If a default value is added then the final data type can be added that prevents the variable from being modified later on in the workflow.
    • Default values accept constant values and JS7 - Expressions for Variables.
  • Any number of order variables can be declared.

Using Order Variables

Order variables can be used in a number of places:

  • to populate environment variables that are used in job scripts,
  • to populate node arguments,
  • to be evaluated by an expression in a JS7 - If Instruction.

Using Order Variables in Shell Jobs

Shell jobs can access order variables by use of environment variables.

Mapping Order Variables to Environment Variables

A mapping is performed with the "Environment Variables" sub-tab of the job property editor:


Explanation:

  • The property editor suggests to use the names of order variables for environment variables.
    • Environment variable names are automatically converted to uppercase letters.
  • Similarly the values of order variables are suggested with a $ prefixing the name of the variable.
    • Consider that only names of existing order variables can be used as the value for an environment variable.
  • In addition to order variables any expressions can be used, for details see

Using Environment Variables with Job Scripts

Environment variables can be used with job scripts according to the syntax of the respective operating system that the job is executed for:

  • for Windows use: %VAR_STRING%
  • For Unix use
    • $VAR_STRING
    • ${VAR_STRING}

Using Node Arguments

Node Arguments are typically used in a situation when the same job occurs more than once in a workflow. The basic assumption is that the job will make use of the same variables that should carry different values per node in which the job is used.

  • Consider that node arguments cannot be modified dynamically - which is why they are called arguments, not variables. 
  • Node arguments are available for mapping to environment variables in a similar manner to order variables.

Creating Order Variables

Order variables can be created dynamically from shell jobs.

  • The job script can append a pair of name and value for a variable to a temporary file indicated with the $JS7_RETURN_VALUES environment variable.
  • The JS7 Agent will pick up the temporary file after execution of the shell job and from the file's entries will create new order variables for subsequent instructions and jobs in the workflow.
  • This mechanism is used to create new order variables from Shell Jobs. It cannot be used to modify existing order variables. Shell jobs always should create new order variables to pass values to subsequent instructions and jobs.


Unix example to dynamically create an order variable
SOME_VARIABLE="some value"
echo "myVar=$SOME_VARIABLE" >> $JS7_RETURN_VALUES
Windows example to dynamically create an order variable
set SOME_VARIABLE=some value
echo "myVar=%SOME_VARIABLE%" >> %JS7_RETURN_VALUES%


Explanation:

  • Both examples assign some value to an environment variable SOME_VARIABLE that is local to the job.
  • The name/value pair myVar=.... is appended to the temporary file indicated by the JS7_RETURN_VALUES environment variable.
    • This assignment makes use of the value stored with the SOME_VARIABLE environment variable.
    • This assignment could use a constant value too instead of using SOME_VARIABLE.

Built-in Variables

Built-in variables are available at the following scopes:

Workflow

  • $js7WorkflowPath
    • The unique name of a workflow. Consider that the name does not include the folder location of a workflow.
  • $js7WorkflowPosition
    • The position of an order in the workflow.
  • $js7Label
    • The label of the current instruction for which an order is executed.
  • $js7OrderId
    • The order identifier.
  • $js7ControllerId
    • The Controller's identifier as specified during installation.

Job

  • $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.



  • No labels
Write a comment…