Editing Job Completion Handlers

Note:  These instructions apply only to Windows installations under IIS.

Job completion handlers are used to run custom handlers at the conclusion of orchestratorClosed Keyfactor orchestrators perform a variety of functions, including managing certificate stores and SSH key stores. jobs. They are configured by placing your custom-built handler in the JobCompleteHandlers directory or a subdirectory of it and editing the manifest.json file in the above directory to appropriately reference your handler.

Keyfactor Command ships with one built-in job completion handler, which is designed to send an email at the conclusion of orchestrator jobs. To configure this handler:

  1. First, determine which types of jobs you wish to send notifications about upon job completion and to whom the notifications should be directed. You will need the job type GUIDs (not job GUIDs) for these jobs and the email addresses for the users or groups to whom the notifications will be sent. To determine the job type GUIDs for your jobs, use the GET /CertificateStoreTypes APIClosed An API is a set of functions to allow creation of applications. Keyfactor offers the Keyfactor API, which allows third-party software to integrate with the advanced certificate enrollment and management features of Keyfactor Command. method (see GET Certificate Store Types) and look in the output for the InventoryJobType, ManagementJobType, and DiscoveryJobType GUIDs for each certificate store type you wish to monitor. These are the GUIDs to reference from the job completion handler.
  2. On the Keyfactor Command server, locate the \WebAgentServices\Extensions\JobCompleteHandlers directory within the install directory. By default, this is:

    C:\Program Files\Keyfactor\Keyfactor Platform\WebAgentServices\Extensions\JobCompleteHandlers
  3. In the JobCompleteHandlers directory, locate the manifest.json file and open it for editing using a text editor.

  4. Update the manifest.json file to contain a reference to the SendEmailOrchestratorJobCompleteHandler handler with configuration as shown below.

    In the Options section, enter a comma-separated list of the users or groups who should receive the notifications that jobs are complete in the EmailRecipients. Enter a comma-separated list of the job type GUIDs (not job GUIDs) that should initiate notifications in the JobTypes.

    To reduce the number of assemblies listed in the shared assemblies file, add the new extension registration option 'LoadInUpstreamContext' that when set to True, causes all of the extension's assemblies to be shared with the calling assembly.

    Copy
    {
       "extensions": {
          "Keyfactor.Platform.Extensions.IOrchestratorJobCompleteHandler": {
             "SendEmailOrchestratorJobCompleteHandler": {
                "assemblypath": "../../CSS.CMS.Agents.Server.dll",
                "TypeFullName": "CSS.CMS.Agents.Server.Handlers.SendEmailOrchestratorJobCompleteHandler",
                "Options": {
                   "EmailRecipients": "john.smith@keyexample.com,martha.jones@keyexample.com",
                   "JobTypes": "d60ff0ad-448c-4498-bd73-a8d8194c73c5,b98621f3-d779-40d3-8f09-eecf32d68183,106478fa-6cbf-4d05-ad31-addaa9675c3c"
                },
                "LoadInUpstreamContext": "True"
             }
          }
       }
    }
  5. Save the manifest.json file.
  6. Restart the web server services (iisreset) on the Keyfactor Command server to complete the implementation.

When a job completion email is delivered, it will contain a subject referencing the type of job and that it is complete (e.g. Keyfactor Orchestrator CitrixAdcInventory Job Complete) with a message similar to:

CitrixAdcInventory job with id '62c40c40-7904-49be-b3f5-4d49f6856ef2' completed with result: Success.
Job was requested on Wednesday, September 27, 2023 for client machine 'websrvr21.keyexample.com'.