You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Introduction

Users frequently find a situation when a job creates some result that should be forwarded to subsequent jobs in a workflow.

Passing Variables

Shell Jobs

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

Example of a Unix Shell job passing variables
#!/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
Example of a Windows Shell job passing variables
@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%

Read Variables

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

The JOC Cockpit GUI offers this

x


Example of a Unix Shell job reading variables
#!/bin/bash

# read results
echo "FIRST_RESULT = $FIRST_RESULT"
echo "SECOND_RESULT = $SECOND_RESULT"
Example of a Windows Shell job passing variables
@rem read results
@echo FIRST_RESULT = %FIRST_RESULT%
@echo SECOND_RESULT = %SECOND_RESULT%

PowerShell Jobs


  • No labels