Promoting a Folder from DEV to PROD

This tutorial demonstrates how to promote a folder and all the jobs within it from a DEV environment to a PROD environment by converting an existing Promotion Rule to a Deploy Descriptor and deploying the resulting definitions to the PROD environment.

You can choose between the following procedures:

For more information, see Promotion.

Running a Folder Promotion Script

This procedure describes how to run a script that performs all actions necessary to promote a folder from DEV to PROD.

Before You Begin

Ensure that you meet the following prerequisites:

  • You have successfully completed API setup, as described in Installation.

  • You have valid credentials for both the DEV and PROD environments and you have network access to the Automation API endpoints of both environments.

  • You have Git installed. If not, obtain it from the Git Downloads page.

  • You have local copies of the tutorial samples from GitHub and a local copy of the source code using the git clone command:

    git clone https://github.com/controlm/automation-api-quickstart.git

Begin

  1. Choose a defined Promotion Rule to remap environment-specific values in the DEV environment (such as names of Control-M/Servers, host groups, or connection profiles) before deployment to the PROD environment.

    In this example, the Promotion Rule is named DEV-TO-PROD.

  2. Access the tutorial sample by running the following command:

    cd automation-api-quickstart/control-m/104-promote-folder-with-existing-promotion-rules

  3. Open the promote_folder.sh file and edit the CONFIG section at the top with custom values for the following parameters:

    • DEV_ENDPOINT: Automation API endpoint URL for the DEV environment

    • PROD_ENDPOINT: Automation API endpoint URL for the PROD environment

    • DEV_USER and DEV_PASSWORD: Access credentials for the DEV environment

    • PROD_USER and PROD_PASSWORD: Access credentials for the PROD environment

    • DEV_SERVER: Control-M/Server that holds the Control-M folder in the DEV environment

    • FOLDER_NAME: Name of the Control-M folder that you want to promote

    • PROMOTION_RULE: Name of the Promotion Rule to apply before deployment

  4. (UNIX) Adjust file permissions to make the script executable:

    chmod +x promote_folder.sh

  5. Run the script:

    ./promote_folder.sh

    The script performs all steps necessary for folder promotion from DEV to PROD, as described below for a manual promotion.

Promoting a Folder Manually

This procedure describes how to perform a manual promotion of a folder from DEV to PROD.

Before You Begin

Ensure that you meet the following prerequisites:

  • You have successfully completed API setup, as described in Installation.

  • You have valid credentials for both the DEV and PROD environments and you have network access to the Automation API endpoints of both environments.

Begin

  1. Register the DEV and PROD environments with environment add API commands:

    ctm env add DEV https://<DEV_ENDPOINT>:8443/automation-api <DEV_USER> <DEV_PASSWORD>

    ctm env add PROD https://<PROD_ENDPOINT>:8443/automation-api <PROD_USER> <PROD_PASSWORD>

  2. Set DEV as the default environment by running the environment set API command:

    ctm env set DEV

  3. Export folder definitions from DEV by running the deploy jobs::get API command:

    ctm deploy jobs::get -s "server=<DEV_SERVER>&folder=<FOLDER_NAME>" > data.json

    Folder definitions (including definitions of all jobs within the folder) are saved in a file named data.json.

  4. Get a list of defined Promotion Rules by running the deploy promotionrules:get API command, and identify the Promotion Rule that you want to use for folder promotion from DEV to PROD. This Promotion Rule remaps environment-specific values in the DEV environment, such as names of Control-M/Servers, host groups, or connection profiles.

    In this example, the Promotion Rule is named DEV-TO-PROD.

  5. Convert your Promotion Rule to a Deploy Descriptor by running the deploy promotionrules:rule::get API command:

    ctm deploy promotionrules:rule::get DEV-TO-PROD > DEV-TO-PROD.json

    The generated Deploy Descriptor is saved in a file named DEV-TO-PROD.json.

    You can, alternatively, author a new Deploy Descriptor, as described in Deploy Descriptor, and save it as a file named DEV-TO-PROD.json.

  6. Apply the rules in the DEV-TO-PROD.json file to the folder definitions for the PROD environment in a new file named prod_data.json. Use the following deploy transform API command:

    ctm deploy transform data.json DEV-TO-PROD.json > prod_data.json

  7. Validate the new folder definitions against the PROD environment by running the build API command:

    ctm build prod_data.json -e PROD

    The build command validates the transformed folder definitions against the PROD environment without deploying the definitions (that is, a dry run). The response includes information about the numbers of folders, jobs, and connection profiles that would be created in a deployment, as in the following example response:

    Copy
    [
      {
        "deploymentFile": "prod_data.json",
        "successfulFoldersCount": 0,
        "successfulSmartFoldersCount": 1,
        "successfulSubFoldersCount": 0,
        "successfulJobsCount": 2,
        "successfulConnectionProfilesCount": 0,
        "successfulDriversCount": 0,
        "isDeployDescriptorValid": false
      }
    ]
  8. Deploy folder definitions to PROD by running the deploy API command:

    ctm deploy prod_data.json -e PROD

    The following response is an example of a successful deployment:

    Copy
    [
      {
        "deploymentFile": "prod_data.json",
        "deploymentState": "DEPLOY FOLDERS 1/1",
        "deploymentStatus": "ENDED_OK",
        "successfulSmartFoldersCount": 1,
        "successfulJobsCount": 2,
        "deployedFolders": [
          "Folder_1"
        ]
      }
    ]