UAC Utility: Jobs As Code (JaC)

UAC Utility: Jobs As Code (JaC)

Disclaimer

Your use of this download is governed by Stonebranch’s Terms of Use, which are available at  Stonebranch Integration Hub - Terms of Use.

Overview

Jobs-as-code is an approach to automating software delivery pipelines in which the job configuration is managed as code. This approach allows developers to manage job configurations like their application code complete with version control, testing, and continuous integration.

Whether you create your Universal Automation Center (UAC) job definitions using the drag-and-drop designer or as code in a development environment, the UAC jobs-as-code solution provides guidance and tools to integrate those definitions with a Git repository.

Version Information

Template Name

Extension Name

Version

Status

Template Name

Extension Name

Version

Status

Jobs As Code

ue-jobs-as-code

2 (Current 2.4.3)

Fixes and new features are introduced. Compatibility starts from UAC/UAG 7.6.0.0 onwards.

Jobs As Code

ue-jobs-as-code

1

Hot Fixes Only (Until UAC 7.3's End of Support).

Refer to Changelog for version history information.

Version 2.3.0 introduces new features compatible only with Universal Controller and Universal Agent of version 7.6 onwards. Therefore, version 2.3.0 or later should not be installed if your Universal Controller & Agent are of version less than 7.6.

Customers are encouraged to upgrade their Universal Agents to 7.6 to benefit from features introduced in version 2.3.0 and later releases.

Version 2.4.0 deprecates proxy-related fields in the template. These fields are now hidden and no longer in use. Customers are encouraged to configure proxy settings using environment variables. For more information, refer to Set Proxies with Environment Variables.

When using Git over HTTPS the default system location for certificate related information is checked (usually /etc/ssl/certs/ and/or /etc/ssl/cert.pem). For other HTTPS network requests this information is provided by the certifi module. The SSL_CERT_DIR and SSL_CERT_FILE environment variables can be set in order to overwrite this default behavior and force all certificate related information to be retrieved from the same location. They can also be set if the underlying system uses some location other than /etc/ssl/certs to store certificate information.

Software Requirements

This integration requires a Universal Agent and a Python runtime to execute the Universal Task.

Area

Description

Area

Description

Python Version

Requires Python Version 3.11.  Tested with Agent bundled python distribution

Universal Agent

Both Windows and Linux agents are supported:

  • Universal Agent for Windows x64 Version >= 7.6.0.0

  • Universal Agent for Linux Version >= 7.6.0.0

Universal Controller

Universal Controller Version >= 7.6.0.0

Network and Connectivity

This integration needs outbound HTTPS connectivity with GitLab, GitHub, Bitbucket Cloud, or Azure DevOps. It also needs outbound SSH connectivity (depending on the Git protocol used) for exporting and importing UAC Definitions, in addition to HTTPS outbound connectivity to the Universal Controller for retrieving the UAC Definitions and importing them from Git.

GitLab

Supported editions:

  • GitLab Community Edition (REST API v16.6)

  • GitLab Enterprise Edition (REST API v16.6)

GitHub

Supported plans:

  • GitHub Free (X-GitHub-Api-Version:2022-11-28)

  • GitHub Pro (X-GitHub-Api-Version:2022-11-28)

  • GitHub Team (X-GitHub-Api-Version:2022-11-28)

  • GitHub Enterprise Cloud (X-GitHub-Api-Version:2022-11-28)

Bit Bucket

Support plans:

  • Bit Bucket Cloud

Azure DevOps

Supported plans:

  • Azure DevOps Services (Cloud Version) for Git Repos hosted on Azure DevOps Platform

Key Features

Feature

Description

Feature

Description

List UAC Definitions

Query UAC definitions prior to running an actual export to Git, to validate the selection criteria, without any write operations in the target repository. This feature should provide a list of UC definitions that can then be exported to a Git repository.

Export to Git Repository

Export selected UAC Definitions to the selected Git Repository. By using this feature, the UAC user will be able to export the selected UAC Definitions to an external Git repository.

After the export, this repository can be used as a backup or as a basis for developer collaboration on top of a source version control system.

Import from Git Repository

Import selected UAC Definitions, already stored in Git, back to the selected Universal Controller. This feature provides the opportunity for restoration of the UC server (recovery scenarios) or for updating UAC Definitions. For UC version 7.3, or higher, the import feature can be triggered by using webhooks.

Feature: Import Mode

The Import Mode input field introduced in version 2.2.0 is available for the "Import from Git Repository" Action. The field covers the following scenarios.

  • "Generic Webhook and Custom" Mode - This mode provides import of UC definitions manually using lists for Add, Modify, or Remove definitions on the Controller, or using Webhook Payloads. For manual imports, operations are processed in the following order: Add operations first, then Modify operations, and finally Remove operations. 

  • "Insert or Update" Mode - This mode provides import of UC definitions manually using a single Modify list for both adding and modifying definitions on the Controller. Each definition specified in the list is separately processed and, based on the presence on the Controller, it is either added or modified. For this mode, there is no specific order requirement. Both add and modify definitions can be included in the list, as the handling is done internally.

In case of dependencies between the entities to be imported, these relationships are automatically detected. Entities are then processed in the correct order. For creation/modification, dependencies are resolved first. For deletion, the order is reversed to prevent conflicts.

Feature Flags

There are cases where some functionalities could become deprecated, and new features are introduced in a stepwise approach to inform customers early enough to take the necessary steps given potential future breaking changes. The activation/deactivation of those features is controlled by Feature Flags. Not all features are entering this lifecycle approach, but when this is applicable, related feature flags are documented. The Feature State Transition diagram and related information is given below:

 

 

The following features are subject to this lifecycle approach

Feature Description

Feature State History

Information

Feature Description

Feature State History

Information

Disable the default commit message prefix.

  • Version 2.0.0: “Default Deactivated”

This is a stable feature. To enable the feature, set environment variable UE_FF_DISABLE_DEFAULT_COMMIT_PREFIX=True. Setting any other value or not setting this environment variable means that the feature is not activated.

 

Supported Actions

Action: List UAC Definitions

Query UAC definitions prior to running an actual export to Git, to validate the selection criteria, without any write operations in the target repository. This feature should provide a list of UC definitions that can later be exported to a Git repository.

Configuration examples

User Scenario: Query all UAC Definitions that are stored in UAC, except Scripts and Custom Days.

 

User Scenario: Query all UAC Definitions that are part of a workflow with the name 'test-workflow', with a proxy connection.

 

Action Output

Output Type

Description 

Example

Output Type

Description 

Example

EXTENSION

Standard Universal Extension format

The extension output follows the standard Extension output format, providing:

  • exit_code, status, status_description: General info regarding the task execution.

  • invocation.fields: The task configuration used for this task execution.

  • result.definitions_selected: The UAC definitions that match the filter provided.

  • result.errors: The list of errors occurred during execution.

{     "exit_code": 0,     "status": "SUCCESS",     "status_description": "List UAC Definitions executed successfully.",     "invocation": {         "extension": "ue-jobs-as-code",         "version": "2.4.3",         "fields": { ... },     },     "result": {         "definitions_selected": {             "agentcluster": 0,             "bundle": 0,             "businessservice": 0,             "calendar": 1,             "databaseconnection": 0,             "emailconnection": 0,             "peoplesoftconnection": 0,             "sapconnection": 1,             "snmpmanager": 0,             "customday": 0,             "emailtemplate": 0,             "script": 0,             "task": 2,             "trigger": 1,             "variable": 1,             "virtual": 0         }     } }
{ "exit_code": 21,     "status_description": "Some errors where produced during data synchronization process: Task completed with failure. See Extension Output for more details.",     "status": "FAILED",     "invocation": {          "fields": { ...          }       },     "result": {     "definitions_selected": {},         "errors": [           "List task failed. Could not find agent with id a379367e65c94b918f46b71b0a69795e."         ]     } }

STDOUT

All definitions matched the selection criteria, in table format.

================= ========= ========================================= Type Subtype Name ================= ========= ========================================= Business Services -  jobs-as-code-win Tasks Manual  jobs-as-code-manual-task-win ================= ========= =========================================

 

Action: Export to Git Repository

Export selected UAC Definitions to the selected Git Repository. By using this feature, the UAC user can export the selected UAC Definitions to an external Git repository. After the export, this repository can be used as a backup or as a basis for developer collaboration on top of a source control versioning system.

Configuration examples

User Scenario: Export UAC Definitions to Gitlab using "HTTP(S)" Git Protocol, contained in the Bundle named uc_bundle, except for Email and Peoplesoft Connections. The selected definitions will be stored under the "/export" folder under the "export/7.3" branch in .yaml format.

 

User Scenario: Export UAC Definitions to Azure DevOps using "HTTP(S)" Git Protocol. Organization and repository names must be included in the Git Service Provider URL.

 

User Scenario: Export UAC Definitions to GitHub using "SSH" Git Protocol, contained in the Bundle named uc_bundle. Sign the commit with the exported definition using a private key. Use the environment variables GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL for setting up the author and committer of the commit. These values can point to the same user, or different users can be the author and committer.

Action Output

Output Type

Description

Example

Output Type

Description

Example

EXTENSION

The extension output follows the standard Extension output format, providing:

{     "exit_code": 0,     "status_description": "SUCCESS: Task executed successfully.",     "status": "SUCCESS",     "invocation": {         "extension": "ue-jobs-as-code",         "version": "2.4.3",         "fields": { ... }     },     "result": {         "definitions_selected": {             "agentcluster": 0,             "businessservice": 1,             "bundle": 0,             "calendar": 0,             "databaseconnection": 0,             "emailconnection": 0,             "peoplesoftconnection": 0,             "sapconnection": 0,             "snmpmanager": 0,             "customday": 0,             "emailtemplate": 0,             "script": 0,             "task": 1,             "trigger": 0,             "variable": 0,             "virtualresource": 0         },         "definitions_exported": {             "agentcluster": 0,             "businessservice": 1,             "bundle": 0,             "calendar": 0,             "databaseconnection": 0,             "emailconnection": 0,             "peoplesoftconnection": 0,             "sapconnection": 0,             "snmpmanager": 0,             "customday": 0,             "emailtemplate": 0,             "script": 0,             "task": 1,             "trigger": 0,             "variable": 0,             "virtualresource": 0         },         "errors": [],     }
{     "exit_code": 21,     "status": "FAIL",     "status_description": "Export to Git Repository failed with error(s).",     "invocation": {         "extension": "ue-jobs-as-code",         "version": "2.4.3",         "fields": { ... }     },     "result": {         "definitions_selected": {             "agentcluster": 0,             "bundle": 0,             "businessservice": 0,             "calendar": 1,             "databaseconnection": 0,             "emailconnection": 0,             "peoplesoftconnection": 0,             "sapconnection": 1,             "snmpmanager": 0,             "customday": 0,             "emailtemplate": 0,             "script": 1,             "task": 2,             "trigger": 1,             "variable": 1,             "virtual": 0         },         "definitions_exported": {             "agentcluster": 0,             "bundle": 0,             "businessservice": 0,             "calendar": 1,             "databaseconnection": 0,             "emailconnection": 0,             "peoplesoftconnection": 0,             "sapconnection": 1,             "snmpmanager": 0,             "customday": 0,             "emailtemplate": 0,             "script": 0,             "task": 2,             "trigger": 1,             "variable": 1,             "virtual": 0         },         errors: [             "Failed to create git object for definition 'TestScript' (Git path: /path/script/TestScript.yml)."         ]     } }

 

STDOUT

All definitions matched the selection criteria, in table format.

================= ========= ========================================= =========================================================== ======== Type Subtype Name Git Path Status ================= ========= ========================================= =========================================================== ======== Business Services - jobs-as-code-win Business Services/jobs-as-code-win.yaml exported Tasks Manual jobs-as-code-manual-task-win Tasks/Manual/jobs-as-code-manual-task-win.yaml exported Scripts Data TestScript Scripts/Data/TestScript.yaml failed ================= ========= ========================================= =========================================================== ========

Action: Import from Git Repository

Import selected UAC Definitions, already stored in Git, back to the selected Universal Controller. This feature provides the opportunity for restoration of the Universal Controller server (recovery scenarios) or for updating UAC Definitions. 

Import UC definitions manually

User Scenario: Import the specified files using Git Protocol "HTTP(S)", stored in the corresponding paths of Add, Modify, and Remove Definitions Lists from GitHub to UAC. Files in the Add list will be added to UAC, files in the Modify list will modify existing definitions, and files in the Remove list will be deleted from UAC.

 

User Scenario: Import from GitHub, using Git Protocol "HTTP(S)", all the files that are stored in the "jac-branch" branch and modify the existing corresponding UAC Definitions.

 

User Scenario: Import from Azure DevOps, using Git Protocol "SSH", the file specified in Modify list, stored in "test-branch".

Import UC definitions automatically via Webhooks

Starting from UAC 7.3 and utilizing Global Universal Events, this integration can be configured to get triggered automatically when a change is made in a Git repository.

With the proper configuration, Universal Events can invoke a Jobs As Code Task, which will parse the Git webhook payload, define the added/modified/removed file lists, and trigger an import execution. 

 

Process Flow

The following image demonstrates the flow of events that occur as soon as a GitLab/GitHub/Bitbucket Webhook is triggered.

Import from Git Repository using Git Webhooks and Global Universal Events

                              

Configuration

The following steps are a guide to setting up UAC and the integrated Git provider’s Webhook to automatically trigger Jobs As Code Tasks.

  1. Create a new Global Event Template that shall receive the Git provider’s Webhook payload. Set option "Unmapped Attributes Policy" to "Include Attributes".

  2. Create a Universal Monitor and link it with the Global Event Template created in Step 1.

  3. Create a Universal Monitor Trigger and assign to it:

    1. The Universal Monitor created in Step 2

    2. A Jobs as Code Task that should be triggered when a new Git Webhook is invoked. The integration task should be configured to utilize the event’s webhook payload (see sections Parse GitLab/GitHub Webhook Payload, Parse Bit Bucket and Azure DevOps Webhook Payload, stored in UAC built-in variable ${ops_trigger_<universal_monitor_name>_payload}.

  4. Set up a repository Webhook in the integrated GitLab/GitHub/BitBucket platform and select the "Push" trigger option. Link the Webhook to the Universal Controller Event created in Step 1 as follows:

    1. If the controller URL is https://somehost.yourdomain.com/uc/, the Webhook’s target URL should be https://<uc_user>:<us_password>@somehost.yourdomain.com/uc/resources/universalevent/push/<name of the event>.
      A Webhook can also be configured with a secret token for enhanced security. More information about this feature can be found for GitHub and GitLab providers.11.

Avoidance of Cyclic Imports

When an “Export to Git Repository” action is performed through a Universal Task, it triggers a push event towards the configured Git Service Provider. This push event leads to the triggering of the Git Service Provider Webhook. If configured as above, this webhook should create a Universal Event to UAC, for further processing to trigger an “Import from Git Repository” action. To prevent this cyclic behavior, a configuration is required to filter out those unnecessary imports. This can be accomplished if the Universal Monitor that listens for Webhook Events triggers a workflow configured appropriately to filter such cyclic requests.

The best practice suggested to filter out those cyclic imports is to ignore the imports initiated by UAC by configuring a dedicated Git user for the “Export” related tasks. The triggered workflow can start with a task that evaluates ${ops_trigger_<universal_monitor_name>_payload} to check if the request is initiated by the UAC git User. If yes, the request can be ignored. If no, the “Import from Git Repository” task can be executed.

The following image demonstrates the example above

Filter out webhooks that were triggered from the "Export to git Repository" Action.

Parse GitLab/GitHub Webhook Payload

In the 'Actions' section of the task, three variables need to be set, one for each import list. The name of the variable should also be put in the corresponding field of the template. The value of the variable should be a UC function that uses a JSON path to extract the added, modified, and removed files from the Git Webhook payload. Parse the UAC variable holding the webhook payload, using UAC built-in JSON Path function: ${_varJsonPath('ops_trigger_<universal_monitor_task_name>_payload','$.commits[*].added[*]','',',')}

 

The Universal Task that will be triggered by the webhook should have the name of the Action Variables inside Add, Modify, and Remove UC Definitions Lists, with the prefix "var:", enclosed in a list, as demonstrated in the example below:

  1. Task variables can also be used with the normal Controller syntax, for instance: ${added_definitions}. However, it is strongly suggested to use the custom [var: <variable name>], in order to avoid reaching size limits due to variable resolution on the fly.

  2. In this scenario, any input in the Webhook Payload field will be ignored.

Parse Bit Bucket and Azure DevOps Webhook Payload

Import from Bitbucket via Webhook

In this scenario, any input in Add/Modify/Remove UC Definition List fields will be ignored.

Import UC definitions: "Insert or Update" Mode

User Scenario: Import from GitHub all the files that match a regular expression pattern stored in the "jac-branch" branch, and add or modify the existing corresponding UAC Definitions.

Action Output

Output Type

Description

Example

Output Type

Description

Example

EXTENSION

The extension output provides the following information:

  • exit_code, status, status_description: General info regarding the task execution.

  • invocation.fields: The task configuration used for this task execution.

  • result.definitions_selected: The UAC definitions that match the filter provided.

  • result.definitions_exported: The UAC definitions are actually exported to the Git provider.

  • result.errors: The list of errors occurred during execution.

"exit_code": 1, "status": "SUCCESS", "status_description": "import from Git Repository executed successfully.", "invocation": { "extension": "ue-jobs-as-code", "version": "2.4.3", "fields": { ... } }, "result": { "definitions_selected": { "agentcluster": 0, "bundle": 0, "businessservice": 0, "calendar": 1, "databaseconnection": 0, "emailconnection": 0, "peoplesoftconnection": 0, "sapconnection": 1, "snmpmanager": 0, "customday": 0, "emailtemplate": 0, "script": 0, "task": 2, "trigger": 1, "variable": 1, "virtual": 0 }, "definitions_added": { "agentcluster": 0, "bundle": 0, "businessservice": 0, "calendar": 1, "databaseconnection": 0, "emailconnection": 0, "peoplesoftconnection": 0, "sapconnection": 1, "snmpmanager": 0, "customday": 0, "emailtemplate": 0, "script": 0, "task": 2, "trigger": 1, "variable": 1, "virtual": 0 }, "definitions_removed": { "agentcluster": 0, "bundle": 0, "businessservice": 0, "calendar": 1, "databaseconnection": 0, "emailconnection": 0, "peoplesoftconnection": 0, "sapconnection": 1, "snmpmanager": 0, "customday": 0, "emailtemplate": 0, "script": 0, "task": 2, "trigger": 1, "variable": 1, "virtual": 0 }, "definitions_modified": { "agentcluster": 0, "bundle": 0, "businessservice": 0, "calendar": 1, "databaseconnection": 0, "emailconnection": 0, "peoplesoftconnection": 0, "sapconnection": 1, "snmpmanager": 0, "customday": 0, "emailtemplate": 0, "script": 0, "task": 2, "trigger": 1, "variable": 1, "virtual": 0 }, errors: [] } }
{ "exit_code": 21, "status_description": "Some errors where produced during data synchronization process: Task completed with failures.See Extension Output for more details.", "status": "FAILED", "invocation": { "extension": "ue-jobs-as-code", "version": "2.4.3", "fields": {...} }, "result": { "definitions_selected": { "agentcluster": 0, "businessservice": 0, "bundle": 0, "calendar": 0, "databaseconnection": 0, "emailconnection": 0, "peoplesoftconnection": 0, "sapconnection": 0, "snmpmanager": 0, "customday": 0, "emailtemplate": 0, "script": 0, "task": 1, "trigger": 0, "variable": 0, "virtualresource": 0 }, "definitions_added": { "agentcluster": 0, "businessservice": 0, "bundle": 0, "calendar": 0, "databaseconnection": 0, "emailconnection": 0, "peoplesoftconnection": 0, "sapconnection": 0, "snmpmanager": 0, "customday": 0, "emailtemplate": 0, "script": 0, "task": 0, "trigger": 0, "variable": 0, "virtualresource": 0 }, "definitions_modified": { "agentcluster": 0, "businessservice": 0, "bundle": 0, "calendar": 0, "databaseconnection": 0, "emailconnection": 0, "peoplesoftconnection": 0, "sapconnection": 0, "snmpmanager": 0, "customday": 0, "emailtemplate": 0, "script": 0, "task": 0, "trigger": 0, "variable": 0, "virtualresource": 0 }, "definitions_removed": { "agentcluster": 0, "businessservice": 0, "bundle": 0, "calendar": 0, "databaseconnection": 0, "emailconnection": 0, "peoplesoftconnection": 0, "sapconnection": 0, "snmpmanager": 0, "customday": 0, "emailtemplate": 0, "script": 0, "task": 0, "trigger": 0, "variable": 0, "virtualresource": 0 }, "errors": [ "Failed to add UAC definition TestScript: Create script failed. A duplicate value has been detected. Name must be unique." ] } }

STDOUT

All definitions matched the selection criteria, in table format.

================= ========= ========================================= =========================================================== ======== Type Subtype Name Git Path Status ================= ========= ========================================= =========================================================== ======== Business Services - jobs-as-code-win Business Services/jobs-as-code-win.yaml imported Tasks Manual jobs-as-code-manual-task-win Tasks/Manual/jobs-as-code-manual-task-win.yaml imported Scripts Data TestScript Scripts/Data/TestScript.yaml failed ================= ========= ========================================= =========================================================== ========

 

Input Fields

The input fields for this Universal Extension are described below.

Field

Type

Description

Version Information

Field

Type

Description

Version Information

Action

Choice

Action performed upon the task execution. Available actions are as follows.

  • List UAC Definitions (default)

  • Export to Git Repository

  • Import from Git Repository

Introduced in 1.0.0

Universal Controller URL

Text

The Universal Controller URL will be used to query and import UC Definitions.

Introduced in 1.0.0

Universal Controller Credentials

Credentials

Universal Controller credentials that provide access to the Universal Controller Web Services.

The user should be configured with "Web Service Access=True".

A PAT (Personal Access Token) can be provided in the Token field of the credential.

Introduced in 1.0.0

UC SSL Certificate Verification

Checkbox

Enables/Disables certificate verification against Universal Controller URL. For example, if self-signed certificates are used to connect with UAC.

Default setting is checked.

Introduced in 1.0.0

Selection Method

Checkbox

Select or filter specific UC Definitions for listing or exporting to Git repository. 
The available options are as follows.

  • Business Service (default)

  • Bundle

  • Definition Name (Regex)

  • Definition Name (Wildcard)

  • Workflow

  • Trigger

Visible only when the selected Action is "List UAC Definitions" or "Export to Git Repository".

If using a "Definition Name" Selection Method, the "Definition Name (Wildcard)" achieves better performance than "Definition Name (Regex)".

Introduced in 1.0.0

Selection Name

Dynamic Choice

The corresponding filter value for the Selection Method field.

When the Selection Method is "Definition Name (Regex)" or "Definition Name (Wildcard)", the value provided in the field works as a filter applied on the UC Definition name.

The value should be a regex or a text with wildcard (depending on the selection method)

  • Example with Regex Filtering: "(^sometext.*|^someothertext.*)"

  • Example with Wildcard Filtering: "task?text*"  

Visible only when the selected Action is "List UAC Definitions" or "Export to Git Repository".

Introduced in 1.0.0

Selection Exclude List

Choice

Exclude various UC Definition types of resources from the selection.

Visible only when the selected Action is "List UAC Definitions" or "Export to Git Repository".

Introduced in 1.0.0

Git Host Verification

Checkbox

Enables/Disables host verification against Git Service Provider URL. 

  • If Git Protocol is "HTTP(S)" the SSL certificate sent by the server is verified.

  • If Git Protocol is "SSH" the host key of the server is verified.

Default setting is checked.

Visible only when the selected Action is "Import from Git Repository" or "Export to Git Repository".

Default setting is checked.

Introduced in 1.0.0

Git Protocol

Choice

The protocol used when accessing a Git repository. 

The available options are as follows.

  • HTTP(S) (default)

  • SSH

Introduced in 2.3.0

Git Service Provider

Choice

The Git service provider the task is using.
The available options are as follows.

  • GitLab (default)

  • GitHub

  • Bitbucket

  • Azure DevOps 

Visible only when the selected Action is "Import from Git Repository" or "Export to Git Repository", and when Git Protocol is "HTTP(S)".

Introduced in 1.0.0

Git Service Provider URL

Text

The Git service provider URL the task is using. 

Examples for each Git Provider Version:

Visible only when the selected Action is "Import from Git Repository" or "Export to Git Repository".

Introduced in 1.0.0

Git Credentials

Credentials

The credentials that should be used to access the Git repository. The Credentials definition should be as follows.