Managing a job definition from the Orchestration CLI
In this topic you can find the syntax to manage a job definition.
In a HCL Universal Orchestrator distributed environment, jobs can be defined either independently from job streams or within a job stream definition.
When creating an item, you can define it in a folder. If no folder path is specified, then the item definition is created in the default folder. By default, it is the root (/) folder, but you can customize it to a different folder path. For more information, see: Configuring Orchestration CLI.
To create new job definitions, the file must start with $jobs. Each job definition has the following format and arguments:
Syntax
[[folder/]workstation#][folder/]jobname
{task job_definition }
[description "description"]
[succoutputcond Condition_Name "Condition_Value"]
[outputcond Condition_Name "Condition_Value"]
To add dependencies to a job definition, you must include them in a job stream definition.
When assigning an alias to a job, ensure that the name is not already used for another job in the same job stream.
The following example shows how the renaming of a job definition can affect the jobs:
Original job definition names in job stream | Rename job definition | Outcome |
---|---|---|
SCHEDULE [folder/]WKS#/APPS/DEV/JS |
Rename job A to D |
SCHEDULE[folder/] WKS#/APPS/DEV/JS |
Rename job B to D |
SCHEDULE WKS#JS |
|
Rename job /APPS/DEV1/A to C | An error occurs when renaming job A to C because job C already exists as the alias for job B. |
Arguments
- [folder/]workstation#
-
Using this keyword, you can define the name of the workstation on which jobs run. The default workstation is the one defined as defaultws in the Orchestration CLI configuration file. A number sign (#) must be placed after the workstation keyword.
- [folder/]jobname
-
Using this keyword, you can define the name of the folder that contains the job definition.
The name must start with a letter, and can contain alphanumeric characters, dashes, and underscores.
If no folder is defined for an item, the default folder (/) is used. For more information, see: Configuring Orchestration CLI
- task job_definition
- Using this keyword, you can define a job definition. Each job type has a specific
syntax.
For more information about syntax and all supported integrations, see Automation Hub.
- description "description"
-
Using this keyword, you can specify a description for the job.
- succoutputcond Condition_Name "Condition_Value"
-
Using this condition, a successor job starts only after the predecessor job or job stream has successfully completed. When this condition is satisfied, the job status is set to SUCC. You can also use this condition to define alternative flows in job streams by specifying the conditions the predecessor job or job stream needs to satisfy before the successor job can start running. Any JSONata boolean expression is accepted. For more information, see: Proprietary functions for JSONata
- outputcond Condition_Name "Condition_Value"
- When satisfied, this output condition defines which job runs as successor. You can define the conditions with the same format used for SUCCOUTPUTCOND. You can find some examples of output conditions below:
-
The following example defines a job named
JOB1
that runs the netstat-an command:
After saving the definition, you can see it displayed as follows:$JOBS WS_AGT_0#/FOLDER1/JOB1 DOCOMMAND "netstat -an" STREAMLOGON "wauser" TASKTYPE WINDOWS RECOVERY STOP
$job /WS_AGT_0#/FOLDER1/JOB1 TASK { "executable" : { "script" : "netstat -an", "credential" : { "userName" : "wauser", "password" : "${password:wauser}" } } } RECOVERY STOP
- The following example defines a job named
JOBDEF1
that runs the ls command:
After saving the definition, you can see it displayed as follows:$JOBS WS_AGT_0#JOBDEF1 TASK <?xml version="1.0" encoding="UTF-8"?> <jsdl:jobDefinition xmlns:jsdl="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdl" xmlns:jsdle="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdle"> <jsdl:application name="executable"> <jsdle:executable interactive="false"> <jsdle:script>ls</jsdle:script> </jsdle:executable> </jsdl:application> </jsdl:jobDefinition> DESCRIPTION "Sample jsdl Job Definition" SUCCOUTPUTCOND COND1 "RC>=0"
$job /WS_AGT_0#/JOBDEF1 DESCRIPTION "Sample jsdl Job Definition" TASK { "executable" : { "interactive" : false, "suffix" : "", "script" : "ls", "credential" : { } } } SUCCOUTPUTCOND COND1 "RC>=0" RECOVERY STOP
- The following example defines a job named
JOBDEF1
, without specifying a workstation:
By default, if the workstation is not specified, the job is saved on the workstation defined in the config.yaml file. After saving the definition, you can see it displayed as follows:$JOBS JOBDEF1 TASK <?xml version="1.0" encoding="UTF-8"?> <jsdl:jobDefinition xmlns:jsdl="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdl" xmlns:jsdle="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdle"> <jsdl:application name="executable"> <jsdle:executable interactive="false"> <jsdle:script>dir</jsdle:script> </jsdle:executable> </jsdl:application> </jsdl:jobDefinition> DESCRIPTION "Sample jsdl Job Definition"
$job /WS_AGT_0#/JOBDEF1 DESCRIPTION "Sample jsdl Job Definition" TASK { "executable" : { "interactive" : false, "suffix" : "", "script" : "dir", "credential" : { } } } RECOVERY STOP
See also
For more information on how to start an Orchestration CLI session refer to Running commands from Orchestration CLI.