Generic Jobs
Use Generic Jobs to define generic, reusable processing steps on any OS Agent. This means that Generic Jobs can be processed on arbitrary host platforms as long as the Agent where they should run is defined. The only prerequisite is that a Generic Job template exists on the target platform. In a fresh Automic Automation installation there are two predefined Generic Job templates (Windows and Unix) in Client 0 but administrators can create as many as needed. Generic Jobs can run independently or they can be added to a Job Group (JOBG) or to a Workflow.
Defining Generic Jobs
A Generic job definition is made up of the following pages:
- Standard pages that are always available, no matter what type of object you are defining:
- Additional pages that are always available for executable objects:
Generic jobs do not have a platform-specific definition page. The platform in which the Job runs and the Agent that the Jobs uses are parameters that are passed to the object at runtime.
Specifying the Agent
Unlike the other Job types in Automic Automation, you cannot select an Agent on the Attributes page. This is because the Agent must be set via a script using the &AGENT# or &OVERWRITE_AGENT# variables. The values of these parameters can be defined in a PromptSet or can be inherited from a variable. For more information, see Inheriting Object and PromptSet Variables.
Important Considerations
-
The &OVERWRITE_AGENT# variable has a higher priority than &AGENT#. If both variables are defined, the &OVERWRITE_AGENT# is used.
-
The Agent must be defined before the script is processed. Therefore, you cannot use :PSET to set the &OVERWRITE_AGENT# or &AGENT# variables.
-
If you use :PUT_ATT to overwrite the Agent, you must not change the platform. This means that, if your &AGENT# variable has the name of a UNIX Agent, you cannot use :PUT_ATT to set a Windows Agent. This action results in a FAULT_OTHER error message.
-
Generic Jobs do not work with Agent Groups (HOSTG). You cannot set &OVERWRITE_AGENT# or &AGENT# to the name of an Agent group.
Custom Template on the Process Page
The Process page contains a custom template that expects a platform-specific script. This template is a case statement that executes a case block depending on the platform.
Example:
You can build and reuse a single Generic job that takes over all your file renaming tasks.
:SWITCH &$PLATFORM#
:CASE "WINDOWS"
ren "&SRC#" "&DST#"
@set retcode=%errorlevel%
@if NOT %ERRORLEVEL% == 0 goto :retcode
:CASE "UNIX"
mv "&SRC#" "&DST#"
:OTHER
:ENDSWITCH
The following information is passed on to the Job at runtime:
-
Which file must be renamed
-
On which Agent
-
Which Login object will be used to access the target system
The values for the &SRC# (source) and &DST# (destination) and the name of the Login object can be defined in a PromptSet or can be inherited from a variable.
You can use :PUT_ATT on the Pre-Process page to overwrite either of the Agent variables. You can also use :PUT_ATT to set platform-specific attributes.
Example
:SWITCH &$PLATFORM#
:CASE "WINDOWS"
:PUT_ATT WIN_WORK_DIR= "c:\temp"
dir
:CASE "UNIX"
:PUT_ATT UNIX_SHELL= "bash"
ls
:OTHER
:ENDSWITCH
See also: