Versions Compared

Key

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

...

Passing Variables

Shell Jobs

First Job: Write Variables

Shell jobs can pass results to subsequent jobs

  • by creating a key/value pair with the syntax: key=value.
  • The key/value pair is appended to a temporary file that is provided by JS7 and that is indicated by the JS7_RETURN_VALUES environment variable.
  • The key provided is the name of the workflow variable that can be used by subsequent jobs.
    • If the variable does not yet exist then it is created on-the-fly.
    • If the variable exists then the value is overwritten


The job script implementation looks like this:

Code Block
languagebash
titleExample of a Unix Shell job passing variables
linenumberstrue
#!/bin/bash

# create results
first_result=$RANDOM
second_result=$RANDOM

# pass results from a key/value pair that is appended to a temporary file provided by JS7
echo "firstResult=$first_result" >> $JS7_RETURN_VALUES
echo "secondResult=$second_result" >> $JS7_RETURN_VALUES
Code Block
languagebash
titleExample of a Windows Shell job passing variables
linenumberstrue
@rem create results
@set first_result=%RANDOM%
@set second_result=%RANDOM%

@rem pass results from a key/value pair that is appended to a temporary file provided by JS7
@echo firstResult=%first_result% >> %JS7_RETURN_VALUES%
@echo secondResult=%second_result% >> %JS7_RETURN_VALUES%

Second Job: Read Variables

Shell jobs access workflow variables and order variables from a mapping to environment variables.

  • The JOC Cockpit GUI offers

...

  • to add the mapping per job from the right lower corner with the sub-tab Environment Variables.
  • The mapping includes to freely choose the name of an environment variable that is used in the job script and to assign an existing workflow variable or order variable.
  • The spelling of variable names is case-sensitivee

Image Added


The job script implementation looks like this:

Image Removed

x

Code Block
languagebash
titleExample of a Unix Shell job reading variables
linenumberstrue
#!/bin/bash

# read results
echo "FIRST_RESULT = $FIRST_RESULT"
echo "SECOND_RESULT = $SECOND_RESULT"

...