Deployer 1.4.0

Welcome to Deployer - created and maintained by Sascha Wildgrube.

Features

The Deployer app provides several tools to support a fully automated CICD pipeline. Its capabilities can be used on target instances for deplyoments - that is the instances to which apps are to be deployed - and on the instance that orchestrates the CICD process.

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.

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.

Deployments represent the specific deployment of an application (and its dependencies) in a given version to a specified Target Instance. As of now Deployer does not conduct any deployment activities itself - it only provides a task list - but stay tuned!

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 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.

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.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 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.

  • Debug

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

  • 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.

  • 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.

  • 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.

  • 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.

  • TriggerNewRepositoyApplicationStatus

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

  • ValidateInstance

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

License

Copyright 2023 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.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