Deployer 1.10.0

Welcome to Deployer - created and maintained by Sascha Wildgrube.

Features

The Deployer app enables fully a automated CICD pipeline based on source control. It installs applications and dependent applications, runs Instance Scan checks, installation scripts and ATF tests automatically.

The Deployer app protects the target instance from unwanted or unexpected data deletion. For each target instance a data deletion policy must be specified.

  • Deny: Data deletion is not allowed as part of a deployment. If applications are selected for deployment which do not (or no longer) contain tables or columns which exist on the target instance the deployment cannot proceed.
  • Confirm: Data deletion is allowed but must be explicitly confirmed during the deployment.
  • Warn: Data deletion is allowed. Users are only warned of data deletion on the target instance.

How the (automated) deployment works

The Deployer app is a remote control that uses REST APIs exposed by the Target Instance. These REST API endpoints allow Deployer to retrieve information on the Target Instance, trigger source control operations, run Instance Scan checks and execute ATF test suites.

Automated Deployment Procedure

  1. Determining the applications to be installed by creating a Repository Application Status. The availability of all application version branches is checked based on the dependency tree.
  2. Install applications and perform CodeSanity checks (Instance Scan) in reverse dependency order. The reverse dependency order is based on the application to be installed and all of its dependencies (and the dependencies of the dependencies). The deepest nodes of the dependency tree are installed first. The application to be installed comes last.
  3. Running installation scripts in reverse dependency order.
  4. Running all ATF tests in reverse dependency order.

CICD Instance features

The "CICD Instance" is an instance that is used to run and operate CICD pipeline automation tools - a control tower.

Repository Credentials need be configured so that the Deployer can access a public or internal source control system based on the repository url alone. Repository Credentials allow to map credential records with specific repository urls or just fractions of urls to cover multiple repositories.

The Repository App Status feature can be used to analyse a given repository and check its readyness for deployment. To access the repositories, the Repository Credentials must be configured.

The current state in an application's "dev" branch can also be assessed using the Repository Application Status feature to get a preview of the result for the application before actually baselining it.

Target Instances need be configured to enable deployments of applications to these instances. The exact steps performed during a deployment can be configured for each Target Instance - e.g., whether to execute the default ATF Test Suite of each installed application and whether CodeSanity checks should be performed during deployment. Each Target Instance can have a type of either DEV, TEST or PROD.

Pipelines can be configured to provide an overview on which applications are installed on which instance.

Deployments represent the specific deployment of an application (and its dependencies) in a given version to a specified Target Instance.

Supported automatic deployment tasks:

  • Installing new versions of imported applications on target instances ("Switch Branch")
  • Installing new versions or refresh the current version of imported applications on target instances ("Apply Remote Changes")
  • Running installation scripts on target instances
  • Running CodeSanity checks on target instances (based on Instance Scan)
  • Running the default ATF Test Suite of applications on target instances

Supported manual deployment tasks:

  • Confirm Data Deletion
  • Importing new applications on target instances ("Import from Source Control")
  • Pre-Deployment Activities
  • Smoke Testing
  • Post-Deployment Activities

Target Instance features

The "Target Instance" is an instance to which applications are to be deployed.

The Deployer app exposes a REST API to check the status of the target instance and to asynchronously execute the installation scripts of an application and all of its dependencies in the correct order.

Disclaimer

Deployer is NOT an officially supported ServiceNow product.

Deployer does NOT come with any kind of warranty. If you use it, you own it!

System Requirements

Installation on target instance

  1. Create an account on GitHub - if not done already.
  2. Create a personal access token for your GitHub account.
  3. Add credentials to access GitHub - use "Basic Auth".
  4. Fork the repository https://github.com/saschawildgrube/servicenow-devtools.
  5. Go to Studio and import the DevTools application from source control.
  6. Perform all installation steps for the DevTools application documented here: https://www.wildgrube.com/servicenow-devtools/ 
  7. Fork the repository https://github.com/saschawildgrube/servicenow-deployer.
  8. Go to Studio and import the Deployer application from source control.
  9. The InstallApp() function must be executed.
    Run the following script as a background script in scope x_snc_deployer:
  10. x_snc_devtools.InstallApp("x_snc_deployer");
  11. Create a technical user and assign the x_snc_deployer.api role to allow a CICD automation tool to be configured to run installation scripts on the target instance remotely.

Installation on CICD instance

  1. Fork the repository https://github.com/saschawildgrube/servicenow-devtools.
  2. Go to Studio and import the DevTools application from source control.
  3. Perform all installation steps for the DevTools application documented here: https://www.wildgrube.com/servicenow-devtools/ 
  4. Fork the repository https://github.com/saschawildgrube/servicenow-deployer.
  5. Go to Studio and import the Deployer application from source control.
  6. The InstallApp() function must be executed.
    Run the following script as a background script in scope x_snc_deployer:
  7. x_snc_devtools.InstallApp("x_snc_deployer");
  8. Configure Repository Credentials to map credential records to one or more source control systems, groups or even individual repositories within these source control systems.
  9. Configure Target Instances to enable deployments of applications to these instances.

Reference

Configuration Options

Roles

  • x_snc_deployer.admin

    A Deployer admin user has access to all configuration and process assets of the Deployer application. The role contains the deployer manager role.

  • x_snc_deployer.api

    The api user is entitled to execute REST API calls against the REST APIs exposed by the Deployer app.

  • x_snc_deployer.developer

    A developer can view all deployer related data and can create new Repsitory Application Status records.

  • x_snc_deployer.manager

    A Deployer manager user can trigger deployments and has read access to all configuration assets and the source control based dependency tree.

  • x_snc_deployer.viewer

    A Deployer viewer user has read access to the Deployer configuration assets and has read access to the source control-derived dependency tree of a given application.

REST APIs

Deployer Target API

The API provides endpoints to be used while installing applications.

  • Get Status

    Method: GET
    URI: /api/x_snc_deployer/target/get_status

  • Run Installation Scripts

    Executes the AppInstall() functions of the given app and its dependencies.
    Method: GET
    URI: /api/x_snc_deployer/target/run_install_scripts

UI Actions

Script Includes

  • AppGetDependencies

    Retrieves information about the app's dependencies to other apps and required versions.

  • AppGetProperty

    Gets a system property of this application.

  • AppInstall

    This script installs Deployer.

  • AppSetDefaults

    Sets all system properties to default values.

  • AppSetProperty

    Sets a system property of this application.

  • CleanUpPackageObject

    Removes all fields from a package record object that are not required for preparing and executing deployments.

  • CleanUpSysDBObjectObject

    Removes all fields from a syS_db_object record object that are not required for preparing and executing deployments.

  • CleanUpSysDictionaryObject

    Removes all fields from a sys_dictionary record object that are not required for preparing and executing deployments.

  • Debug

    Produces a log output in the application log using the DevTools Debug function.

  • DeployerClientAPI

    Provides functions to be called from UI scripts.

  • DevTools

    Implements the extension point for DevTools.

  • DevToolsGetApplicationStatus

    The function DevToolsGetApplicationStatus is called by the DevTools extension point instance class and returns the application status object with additional status information to be displayed on the "DevTools Application Overview" page.

  • DevToolsGetFormatConfig

    The DevToolsGetFormatConfig function is called by the DevTools extension point instance class and returns an object with field formatting information.

  • DevToolsGetInstancePipelineName

    The function DevToolsGetInstancePipelineName is called by the DevTools extension point instance class and returns the pipeline name of an instance based on the given actual name.

  • DevToolsGetLinkDirectory

    The DevToolsGetLinkDirectory function is called by the DevTools extension point instance class and returns an extended (or modified) link directory object that serves as the basis for the DevTools Link page.

  • DevToolsGetParentRecord

    The DevToolsGetParentRecord function is called by the DevTools extension point instance class and returns a parent record for the given record if it can be determined.

  • DevToolsRenderDebugDump

    The function DevToolsRenderDebugDump is called by the DevTools extension point instance class and returns additional debug information provided by the application.

  • GetApplicationListFromInstance

    Returns the array of applications from an instance.
    This is a deprecated proxy of the function TargetInstanceGetApplicationList().

  • GetApplicationStatus

    Retrieves an array of objects representing the applications available on the target instance.

  • GetCredentialForRepository

    Retrieves a credential record for the given repository based on the configured Repository Credential records. If no match is found or no valid repository url is provided, the function returns false.

  • GetDeploymentTasks

    Returns the status object including the required deployment tasks based on the given status and instance objects.

  • GetLatestRepoDependencyList

    Returns the latest available dependency list for the given repository and version or false if no status is available.

  • GetLatestRepoDependencyStatus

    Returns an object containing the latest available dependency list and tree for the given repository and version or false if no status is available.

  • GetLatestRepoDependencyTree

    Returns the latest available dependency tree for the given repository and version or false if no status is available.

  • GetLinkDirectoryCICD

    Returns a link directory with useful links regarding CICD topics in ServiceNow.

  • GetPipelineStatus

    Retrieves the status information for a given pipeline.

  • GetRepoDependencyList

    Returns an array of objects representing the packages representing the dependency list based on the given repository url and the desired version.

  • GetRepoDependencyTree

    Returns the dependency tree based on the given repository url and the desired version.

  • GetRepositoryType

    Returns the type identifier for a given repository url. The function returns false of the type could not be determined.

  • IdentifyDataDeletion

    Identifies the tables (sys_db_object) and columns (sys_dictionary) which are going to be deleted based on the current list of applications on an instance and the to-be-installed list of applications.

  • IsActive

    Returns true if the application is active, otherwise false.

  • IsBranchDeployable

    Returns if the given branch name indicates whether the branch is deployable. The branch must either be named "master" or contain a semantic version.

  • Log

    Produces a log output in the application log.

  • LogError

    Produces an error log output in the application log.

  • LogWarning

    Produces a warning log output in the application log.

  • SourceControlAPI

    The class acts as an interface to source control repositories in GitHub or GitLab.

  • TargetInstanceATFTestSuiteRun

    Runs the ATF test suite on the given target instance. Returns the progress id of the running suite if successful, or false in case of error.

  • TargetInstanceCICDCheckProgress

    Checks the progress of a running ATF test suite on the given target instance.

  • TargetInstanceGetApplicationList

    Returns the array of applications from the given target instance.

  • TargetInstanceGetStatus

    Returns the array of applications from the given target instance.

  • TargetInstanceInstanceScanRunSuiteOnApp

    Runs the ATF test suite on the given target instance. Returns the progress id of the running suite if successful, or false in case of error.

  • TargetInstanceRequest

    Requests the given end point of the Deployer Target API on the given target instance.
    The credentials used for the request are taken from the credentials associated with the target instance.

  • TargetInstanceRunInstallScripts

    Runs install scripts on the given target instance for the given application.

  • TargetInstanceSourceControlApplyChanges

    Triggers the action "Apply Remote Changes" for the given application for the current branch on the target instance.

  • TargetInstanceSourceControlImport

    Imports an application from source control on the target instance.

  • TargetInstanceValidate

    Returns true if the given instance is correctly configured and accessible.

  • TriggerNewRepositoyApplicationStatus

    Triggers the background process to create a new repository application status based on a given repository url and version.

  • ValidateInstance

    Deprecated proxy for the new TargetInstanceValidate() function for backward compatibility.

License

Copyright 2023-2024 by Sascha Wildgrube

Licensed under the Apache License, Version 2.0 (the "License")

You may not use Deployer except in compliance with the License.

You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Release Notes

1.10.0 - 2024-02-29

  1. DevTools 1.82.0 is now required.
  2. Deployer 1.10.0 requires the same version or higher on the target instance due to updated identification of data deletion.
  3. The detection of data deletion now considers "cloned" dictionary records on TPP tables (like tables derived from cmdb_ci).
  4. The Deployment form no longer reloads if the "Close Notes" have been edited.
  5. The Deployment Task form now reloads when the status changes to update the UI Action buttons.
  6. The Deployer - Repository Viewer page was not displayed properly when using Polaris dark theme. This has been fixed.
  7. The display value of a "Repository Application Status" now indicates that the date/time is in UTC.
  8. Modified ATF test for GetLatestRepoDependencyList() to avoid test flakyness.

1.9.1 - 2024-02-15

  1. Fixed a bug related to generating the result urls in deployment tasks to navigate to test and scan results on the target instance.
  2. In the Pipeline status view page, "null" was displayed if a platform app scope is configured for a target instance, but the app is not installed on the target instance. This has been fixed.

1.9.0 - 2024-02-14

  1. A data deletion policy can be specified for each target instance and is enforced upon deployment.
  2. Introducing the concept of Pipelines.
  3. Deployer 1.9.0 requires the same version or higher on the target instance due to the newly introduced identification of data deletion.
  4. DevTools 1.81.0 is now required because of GetAppDefaultTestSuite().
  5. A repository application status can now be established for the current state in a dev branch.
  6. Deployment Tasks to run CodeSanity checks and ATF test suites now contain a link to the results on the target instance.
  7. The checkbox "Enforce Downgrade" on the Deployment form was not read-only by default. This has been fixed.
  8. The "Prepare" button is now hidden if no instance has been selected yet for a deployment.
  9. The "Run Installation Scripts" REST API endpoint no longer requires the "async" parameter - to ensure full backward compatibility.
  10. The Deployment and the Repository Application Status forms now reload when there is a status change.
  11. The actual start and end date and time is recorded for every deployment.
  12. The "Show Task List" UI Action on the Deployment form is now only visible in draft state.
  13. Deployments can now be cancelled while in ready state.

1.8.0 - 2024-01-16

  1. Deployer is fully tested in Vancouver.
  2. Tokyo is no longer actively supported.
  3. DevTools 1.79.0 is now required because of StringStripTrailingSlash() and DevToolsWorkerAPI::InstallApp().
  4. Deployer 1.8.0 now requires the same version or higher on the target instance due to the asynchronous execution of installation scripts.
  5. Deployer can now properly handle a repository url path with a trailing slash.
  6. The "Prepare" UI Action is no longer available for new deployments. Some options are instance specific and can only be selected once the deployment has been saved with a selected target instance.
  7. Added table x_snc_deployer_deployment_task to the link directory.
  8. When deleting a Deployment, associated Deployment Tasks are now deleted, too.
  9. Improved feature description and installation instructions in the manual.

1.7.0 - 2023-11-17

  1. Added more supported automatic deployment tasks: Installing applications from source control via switch branch/apply remote changes.
  2. Now supporting instance specific manual pre and post deployment activities.

1.6.0 - 2023-11-10

  1. Deployer now requires Deployer 1.6.0 or higher on the target instance because the technical user requires additional roles and the "Get Status" endpoint delivers additional information about the applications - including the Sys ID of the default ATF Test Suite.
  2. Deployer now requires DevTools 1.75.1 because HttpRequest() now handles exceptions thrown by RESTMessageV2::execute(). This allows for proper error handling when communicating with the target instance.
  3. Introducing deployment tasks which represent the individual steps of a deployment - supporting both manual and automated activities.
  4. Supported automatic deployment tasks: Running installation scripts, running CodeSanity checks, and executing the default ATF Test Suite.
  5. A (manual) smoke test procedure can be specified per instance.
  6. Introduced the x_snc_deployer.developer role to allow developers to create a new Repository Application Status to check if their baselined applications are ready for deployment.
  7. The user can specify if the deployment should be automated (where possible) or be conducted manually.
  8. A deployment cannot start while another deployment on the same target instance is in progress.
  9. Added related list of deployments to "Repo App Status" and "Target Instance" forms.
  10. Added UI action "Create Deployment" both on the "Repository Application Status" and the "Target Instance" forms.
  11. The x_snc_deployer.api role now contains the sn_cicd.sys_ci_automation role which is required to operate the sn_cicd API endpoints.
  12. The x_snc_deployer.api role now contains the admin role which - due to a platform deficiency - is required to run ATF tests remotely.

1.5.0 - 2023-10-30

  1. DevTools 1.74.0 is now required due to a bugfix in GetDependencyListFromTree().
  2. Added state model to deployments to represents the status properly.
  3. Added UI action "New Version" to create a new Repo App Status for a new version.
  4. Users with the x_snc_deployer.viewer role now have read access to the basic_auth_credentials table.
  5. Users with the x_snc_deployer.manager role now also inherit the credential_admin role and hence have write access to the discovery_credentials table.
  6. Users with the x_snc_deployer.manager role can now edit all fields on the deployment record.
  7. The related link "Show task List" now only shows after the deployment has been created.
  8. If logging.verbosity is set to "debug" HtmlRenderRepoDependencies() displays the raw data of the repository status.
  9. Improved status display in HtmlRenderRepoDependencies().
  10. Added "Credentials" menu item.
  11. The system property "x_snc_deployer.required_target_version" now defines the minimum version of the Deployer app that must be installed on the target instance.
  12. Menu items "Log" and "Test Suite" are only visible for x_snc_deployer.admin users.

1.4.0 - 2023-09-22

  1. A deployment can now be configured to either enforce downgrades - to exactly match the versions contained in the repositories - or to leave more current versions on the target instance.
  2. A deployment can now be configured to refresh application versions that are already installed on the target instance (or not).
  3. A deployment can now be configured to skip the execution of CodeSanity checks on the target instance.
  4. A deployment can now be configured to skip the execution of the default ATF Test Suites of applications on the target instance.
  5. Deployer Target API / Get Status now also returns the application status.
  6. Added function GetApplicationListFromInstance() to retrieve an array of applications and customization applications from a target instance.

1.3.0 - 2023-09-18

  1. Introduced the "Deployment" table to keep track of deployments.
  2. Added the "Show Task List" UI action to show a wiki-formatted task list for the deployment.
  3. Introduced the "Instance" table to keep configuration and credential references for target instances.
  4. The "Validate" UI action can be used to verify if an instance is properly configured and if the credentials enable the execution of API calls on the instance.
  5. Added function GetDeploymentTasks() to determine the required deployment tasks based on a given application deployment status and a target instance.
  6. GetLatestRepoDependencyTree() now contains the field "repository_application_status" which contains the Sys ID of the status record from where the information was gathered.

1.2.0 - 2023-07-31

  1. Added function GetLatestRepoDependencyStatus().
  2. Added function CleanUpPackageObject() to avoid not necessary fields in the objects returned by functions determining the application repository status.
  3. Avoiding flakyness for ATF tests for GetLatestRepoDependencyList() and GetLatestRepoDependencyTree().
  4. Improved feature and installation documentation in manual.

1.1.0 - 2023-07-25

  1. Deployer is now fully tested in Utah.
  2. San Diego is no longer actively supported.
  3. DevTools 1.65.0 is now required because of the contained GitLabAPI and GitHubAPI classes and the new GetDependencyListFromTree() function.
  4. Deployer now supports the analysis of the deployment readyness of an application version stored in a source code repository.
  5. The exposed functions allow pipeline automation apps to use the repository application status information as input.
  6. Added x_snc_deployer.viewer, x_snc_deployer.manager and x_snc_deployer.admin roles.
  7. The Deployer menu is now accessible to users with the x_snc_deployer.viewer role.
  8. Removed the menu item "Repository Viewer (ad-hoc)".
  9. Added function GetCredentialForRepository().
  10. Added function GetRepositoryType().
  11. Added function SourceControlAPI::GetRequestCount().
  12. Added function IsBranchDeployable().
  13. Added function GetLatestRepoDependencyTree().
  14. Added function GetLatestRepoDependencyList().

1.0.0 - 2023-02-24

First baselined version