Table of Contents |
---|
Introduction
This article describes how the substitution of parameter values works in JobScheduler. It also describes how to use parameters in shell script, API Jobs and pre- and postprocessing scripts.
Substitution of parameter values by the JobScheduler
The JobScheduler can substitute the values of environment variables in task parameters using ${<env_var>}
.
The JobScheduler will substitute ${<env_var>
with empty
when the }
with an empty
value if the environment variable is unknown.
To avoid this the value prevent substitution the environment variable can be quoted with a backslash - i.e. \${<env_var>}
Example
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
<job name="job_environment"> <params > <param name="param_from_environment" value="the value of scheduler_home is ${SCHEDULER_HOME} ${test}"/> </params> <script language="shell"> <![CDATA[ echo %SCHEDULER_PARAM_PARAM_FROM_ENVIRONMENT% ]]> </script> <monitor name="process0" ordering="0"> <script language="java:javascript"> <![CDATA[ function spooler_process_before(){ spooler_log.info("param_from_environment=" + spooler_task.params.var("param_from_environment")); return true; } ]]> </script> </monitor> <run_time /> </job> |
This job will produce the following output when running:
Code Block | ||||
---|---|---|---|---|
| ||||
2015-12-07 10:39:32.458+0100 [info] SCHEDULER-918 state=starting (at=2015-12-07 10:39:32.403+0100) 2015-12-07 10:39:33.984+0100 [info] param_from_environment=the value of scheduler_home is C:/Program Files/sos-berlin.com/jobscheduler/scheduler_current 2015-12-07 10:39:33.987+0100 [info] SCHEDULER-987 Starting process: "C:\WINDOWS\TEMP\\sos-A4CFC1B980.cmd" 2015-12-07 10:39:34.019+0100 [info] [stdout] 2015-12-07 10:39:34.019+0100 [info] [stdout] C:\Users\ur\Documents\sos-berlin.com\jobscheduler\scheduler_current>echo the value of scheduler_home is C:/Program Files/sos-berlin.com/jobscheduler/scheduler_current 2015-12-07 10:39:34.019+0100 [info] [stdout] the value of scheduler_home is C:/Program Files/sos-berlin.com/jobscheduler/scheduler_current |
...
${test}
has been substituted toempty
an empty value- To access the value of the parameter in a shell script, the name must has to be prefixed. The default value of the prefix is:
SCHEDULER_PARAM_
- This prefix can be set by the
scheduler.variable_name_prefix
parameter which is defined in the$scheduler_data/config/scheduler.xml
file.- JobScheduler has to be restarted after the value of the prefix has been changed.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> <?xml-stylesheet type="text/xsl" href="scheduler_documentation.xsl" ?> <spooler> <config mail_xslt_stylesheet="config/scheduler_mail.xsl" port="4102"> <params> <param name="scheduler.variable_name_prefix" value="SCHEDULER_PARAM_"/> <param name="scheduler.order.keep_order_content_on_reschedule" value="false"/> </params> |
Note: JobScheduler does NOT substitute environment variables in order parameters.
Substitution of parameter values by sos.scheduler.managed.configuration.ConfigurationOrderMonitor
An add additional substitution mechanism for jobs running in a job chain is provided by the sos.scheduler.managed.configuration.ConfigurationOrderMonitor
preprocessing java Java class:
This preprocessing java class does the followingJava class implements:
- Before processing:
- it copies the node parameters that are defined configured in
jobchain.config.xml
into the to the order parameters - if an order parameter exists with the same name already exists, then it will be overwritten
- substitutes all
${<param>}
variables with:- JobScheduler parameters that are defined configured in the
$scheduler_data/config/scheduler.xml
file, - task parameters that are defined configured in the actual currently running job,
- order parameters that are defined in configured with the order,
- node parameters that has have been copied to the order parameters.
- JobScheduler parameters that are defined configured in the
- it copies the node parameters that are defined configured in
- After processing:
- deletes all node parameters from the order.
...
- If a task parameter value is to be substituted by the configurationMonitor Configuration Monitor then the value has to be quoted with a backslash to avoid the prevent its substitution by the JobScheduler
- Example:
a value \${param}
- Example:
- If With the parameter setting
scheduler.order.keep_order_content_on_reschedule=true
the values will be substituted only in the first run. - When using node parameters the configurationMonitor must then the Configuration Monitor has to be assigned to the job
- JOE will assign the configurationMontitor Configuration Monitor automatically when defining configuring a node parameter in a job chain
- if substitution does not work, Should no substitution be performed then please check whether if the configuration monitor Configuration Monitor is assigned to the job
- if not make the assignment manually with JOE.
...
- . Otherwise assign parameters individually by using JOE.
Substitution of parameter values by JITL Jobs that extend the JobSchedulerJobAdapter
base class
Some JITL - Jobs extend the JobSchedulerJobAdapter
base class and some older jobs extend JobSchedulerJob
. For a detailed list see here: JITL Jobs - Status
This article describes the substitution in mechanisms for JITL - Jobs that extend the JobSchedulerJobAdapter
base class.
Substitiution Substitution is carried out for:
- task parameters and
- order parameters
...
Where param
can be:
- a task parameter
- a an order parameter
- a node parameter
- a scheduler parameter
- some special values (see the list below)
...
- Parameters named
param
andscheduler_param_param
will be treated as being identical. - Parameters named
param_plus_any_understrikes
andparamplusanyunderstrikes
will be treated as being identical.
Note: Substitution only applies for exclusively to the current job run. That This means that the values of the parameters will be unsubstituted unchanged after the execution of the job. If you have an order parameter param_x
whose value is value
is ${param_y}
and there are two steps in the job chain, the value of param_x
after the execution of the first node will still be
value
is
${param_y}
...