Introduction
Parameters can be set for jobs and orders.
Order parameters are available to all the jobs in a job chain. When the value of an order parameter in a job chain is changed then this new value will be applied at the start of the next (persistent) order.
Note that when jobs are programmed using the JobScheduler API, job and order parameters are separate objects. Node and order parameters form the same object, although here node parameters have priority over order parameters of the same name.
Delimitation
Parameters can also be set for job chains and job chain nodes. However these parameters are used differently to job and order parameters and are not described in this article.
For more information about job chain and job chain node parameters see:
Setting Parameters for a Job or an Order in JOE
The Parameter function can be found in the JOE element tree as a sub-element of every Job and Order. Each parameter consists of a name and a value.
Setting a Job Parameter
- Select a job in JOE's element tree view
- Select the job's Parameter element as shown in the screenshot below
- Enter a name-value pair in the Name and Value fields as shown in the screenshot below.
- Click the Apply button
- Click the Save Configuration icon (top, left) to permanently save the parameters.
Setting an Order Parameter
Order parameters are set in a similar manner to job parameters, by selecting an order's parameter element (not shown in the screen shot above).
Job and Order Parameters as XML
The next two code blocks show the XML generated by JOE for a typical simple job and order:
<job order="yes" stop_on_error="no" name="job1_shell_with_parameter_set"> <params > <param name="param1" value="Value1-Job1"/> <param name="param2" value="Value2-Job1"/> </params> <run_time /> </job>
<order job_chain="shell_with_parameter" id="shell_with_parameter"> <params > <param name="param1" value="Value1-Order1"/> <param name="param2" value="Value2-Order1"/> </params> <run_time /> </order>
Reading and Setting Parameters in Shell Scripts
Parameters can be read and set in shell scripts when they are mad available as environment variables
An environment variable of the form:
- $SCHEDULER_PARAM_[PARAM-NAME] (Unix™)
- %SCHEDULER_PARAM_[PARAM-NAME]% (Windows™)
can be used to read any parameter in a shell script.
Parameters in a shell script can be added and modified using:
- echo "[PARAM-NAME]=[PARAM-VALUE]" >> $SCHEDULER_RETURN_VALUES (on Unix™ systems)
echo [PARAM-NAME]=[PARAM-VALUE] >> %SCHEDULER_RETURN_VALUES% (on Windows™ systems)
Check to see if the testParam parameter, described in the last chapter (page 28), has been set. As an example of the reading and writing of parameters, modify the scripts of the quickstart/firstOrderJob and quickstart/secondOrderJob Jobs as follows:A first order job for Windows@echo off echo %SCHEDULER_JOB_NAME% processed %SCHEDULER_ORDER_ID% echo Current Timestamp: %DATE% %TIME% echo Parameter testParam = "%SCHEDULER_PARAM_TESTPARAM%" echo Parameter testParam is modified to "123456789" echo testParam=123456789 >> %SCHEDULER_RETURN_VALUES% exit %ERRORLEVEL%
Example: firstOrderJob for Windows™
#!/bin/sh echo "$SCHEDULER_JOB_NAME processed $SCHEDULER_ORDER_ID" echo "Current Timestamp: `date`" echo "Parameter testParam = \"$SCHEDULER_PARAM_TESTPARAM\"" echo "Parameter testParam is modified to \"123456789\"" echo "testParam=123456789" >> $SCHEDULER_RETURN_VALUES exit $?
Example: firstOrderJob for Unix™
@echo off echo %SCHEDULER_JOB_NAME% processed %SCHEDULER_ORDER_ID% echo Parameter testParam = "%SCHEDULER_PARAM_TESTPARAM%" dir .\config\live\quickstart exit %ERRORLEVEL%
Example: secondOrderJob for Windows™
#!/bin/sh echo "$SCHEDULER_JOB_NAME processed $SCHEDULER_ORDER_ID" echo "Parameter testParam = \"$SCHEDULER_PARAM_TESTPARAM\"" ls -l ./config/live/quickstart exit $?
Example: secondOrderJob for Unix™
Both Jobs read the testParam parameter, whilst the quickstart/firstOrderJob Job changes the value of the
parameter. testParamHello World! is the initial parameter setting for the quickstart/firstOrderJob Job. This value will be overridden by the Order
Now start the Order for the quickstart/firstJobChain Chain in JOC and follow its progress in the log file.
Further References
Job and Order Parameters
- How to access order parameters and job parameters
- How to pass parameters to subsequent shell jobs in a job chain
- How to dynamically use node parameters and internal parameter substitution
- How to clone parameters from a persistent order