Managing a task definition from the Orchestration CLI
In this topic you can find the syntax to manage a task definition.
In a HCL Universal Orchestrator distributed environment, tasks can be defined either independently from workflows or within a workflow 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 the Orchestration CLI.
To create new task definitions, the file must start with $jobs. Each task 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 task definition, you must include them in a workflow definition.
When assigning an alias to a task, ensure that the name is not already used for another task in the same workflow.
The following example shows how the renaming of a task definition can affect the tasks:
| Original task definition names in workflows | Rename task definition | Outcome |
|---|---|---|
|
SCHEDULE [folder/]WKS#/APPS/DEV/WF |
Rename task A to D |
SCHEDULE[folder/] WKS#/APPS/DEV/WF |
| Rename task B to D |
SCHEDULE WKS#WF |
|
| Rename task /APPS/DEV1/A to C | An error occurs when renaming task A to C because task C already exists as the alias for task B. |
Arguments
- [folder/]workstation#
-
Using this keyword, you can define the name of the workstation on which tasks 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 task 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 the Orchestration CLI.
- task job_definition
- Using this keyword, you can define a task definition. Each
task 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 task.
- Affinity
- You can add this optional attribute in the task definition to run a specific task on the same workstation where the main task runs. For more information, see Affinity.
- succoutputcond Condition_Name "Condition_Value"
-
Using this condition, a successor task starts only after the predecessor task or workflow has successfully completed. When this condition is satisfied, the task status is set to SUCC. You can also use this condition to define alternative flows in workflows by specifying the conditions the predecessor task or workflows needs to satisfy before the successor task 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 task 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 task named
JOB1that runs the netstat-an command:
After saving the definition, you can see it displayed as follows:$JOBS WS_AGT_0#/FOLDER1/TASK1 DOCOMMAND "netstat -an" STREAMLOGON "wauser" TASKTYPE WINDOWS RECOVERY STOP$job /WS_AGT_0#/FOLDER1/TASK1 TASK { "executable" : { "script" : "netstat -an", "credential" : { "userName" : "wauser", "password" : "${password:wauser}" } } } RECOVERY STOP - The following example defines a task named
TASKDEF1that runs the ls command:
After saving the definition, you can see it displayed as follows:$JOBS WS_AGT_0#TASKDEF1 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 Task Definition" SUCCOUTPUTCOND COND1 "RC>=0"$job /WS_AGT_0#/TASKDEF1 DESCRIPTION "Sample jsdl Task Definition" TASK { "executable" : { "interactive" : false, "suffix" : "", "script" : "ls", "credential" : { } } } SUCCOUTPUTCOND COND1 "RC>=0" RECOVERY STOP - The following example defines a task named
TASKDEF1, without specifying a workstation:
By default, if the workstation is not specified, the task 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 Task Definition"$job /WS_AGT_0#/TASKDEF1 DESCRIPTION "Sample jsdl Task 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.