- Users frequently find the situation that jobs in a workflow pass variables to subsequent jobs.
This can easily be achieved by appending a pair of name/value for the variable to a temporary file that is offered by the
JS7_RETURN_VALUESenvironment variable like this:
- A variable
my_variableis passed as an order variable to subsequent jobs and instructions in a workflow.
- The variable can be assigned a constant value or a value from some environment variable as e.g.
MY_VARthat holds some arbitrary value.
- A variable
- 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, 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 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 to be executed in sequence:
- The first job creates a lengthy e-email body in HTML format,
- The second job sends e-mail and makes use of the HTML body. Find 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 some template file as e.g. for 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.