- Users frequently find the situation that jobs in a workflow pass variables to subsequent jobs.
This can easily be achieved by appending a name/value pair for the variable to a temporary file that is offered by the
JS7_RETURN_VALUESenvironment variable like this:
my_variablevariable is passed as an order variable to subsequent jobs and instructions in a workflow.
- This variable can be assigned a constant value or a value from an arbitrary environment variable such as e.g.
MY_VARwhich holds an arbitrary value.
- However, there are two limitations about this approach:
- The length of values for environment variables is limited - the precise max. size of environment variables is OS dependent.
- If the value of the variable includes special characters such as carriage return, newline or linefeed then this might break depending on capabilities of environment variables in the OS.
- To address the problem of special characters, use base64 encoding for variable values as this encoding results in a single printable string.
- To address the limitation concerning the size of environment variables do not use them and instead think about ways how to directly append lines to the temporary file indicated by
- FEATURE AVAILABILITY STARTING FROM RELEASE 2.2.0
- Let's assume two jobs are to be executed in sequence:
- the first job creates a lengthy e-email body in HTML format and
- the second job sends an e-mail and using the HTML body.
- There are a number of possible implementations for the JS7 job script:
In fact the e-mail body is not too lengthy. However, it suggests that an e-mail body of arbitrary size would be imported by a template file as, for example, in the case of PowerShell, with
$mailBody = Get-Content "mail-body.html"
- The above bash version with files and the PowerShell version both work with arbitrary length values.
- Base64 encoding is available from a number of sources such as the
base64Unix utility or the .NET Core class.
- The value of the
bodyvariable is prefixed with
base64:to indicate the encoding.
- The subsequent JS7 - JITL MailJob accepts the
bodyvariable, identifies the encoding and automatically decodes the argument value.