Editing Part of an Existing Flow

This tutorial demonstrates how to modify a single job within a flow, without changing any other jobs or folders in the flow.

Before you begin

Ensure that you meet the following prerequisites:

  • You have successfully completed API setup, as described in Setting Up the API.

  • 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. Access the tutorial sample with the following command:

    cd automation-api-quickstart/helix-control-m/102-Editing-part-of-an-existing-flow

  2. Run the JSON code to a specific environment, using the following command:

    ctm run folderWithTwoProjects.json -e testEnvironment

    This command runs a sample JSON file that contains definitions of a folder with two subfolders and one job in each subfolder.

    The -e option specifies a destination environment that differs from the default environment.

    Ensure that the version of the destination environment matches the version of the CLI.

  3. Review the output, as in the following example, and ensure that the folder ran successfully and the output contains the run ID and a status URI. Take note of the run ID, to use in the next step.

    Copy
    {
       "runId": "fed27cd0-ef20-47c0-9c0c-9bc37ce239bc",
       "statusURI": "https://sqa/automation-api/run/status/fed27cd0-ef20-47c0-9c0c-9bc37ce239bc"
    }
  4. Retrieve the run status of all elements—the folder, two subfolders, and two jobs—using the run status command, as in the following example command and response.

    Note that the "status" property of the job_to_modify job is returned as "Ended Not OK".

    Copy
    > ctm run status fed27cd0-ef20-47c0-9c0c-9bc37ce239bc -e testEnvironment

    {
      "completion": "Completed",
      "statuses": [
        {
          "jobId": "IN01:000ci",
          "folderId": "IN01:",
          "numberOfRuns": 1,
          "name": "Folder_1",
          "folder": "Folder_1",
          "type": "Folder",
          "status": "Ended Not OK",
          "held": false,
          "deleted": false,
          "cyclic": false,
          "startTime": "Sep 4, 2022, 5:22:49 PM",
          "endTime": "Sep 4, 2022, 5:22:52 PM",
          "estimatedStartTime": [
            "20220904172630"
          ],
          "estimatedEndTime": [
            "20220904173130"
          ],
          "orderDate": "220904",
          "ctm": "IN01",
          "description": "",
          "host": "sqa",
          "application": "",
          "subApplication": "",
          "outputURI": "Folder has no output",
          "logURI": "https://sqa/automation-api/run/job/IN01:000ci/log"
        },
        {
          "jobId": "IN01:000cj",
          "folderId": "IN01:000ci",
          "numberOfRuns": 0,
          "name": "Project_Folder1",
          "folder": "Folder_1",
          "type": "Sub-Table",
          "status": "Ended Not OK",
          "held": false,
          "deleted": false,
          "cyclic": false,
          "startTime": "Sep 4, 2022, 5:22:49 PM",
          "endTime": "Sep 4, 2022, 5:22:51 PM",
          "estimatedStartTime": [
            "20220904172630"
          ],
          "estimatedEndTime": [
            "20220904173130"
          ],
          "orderDate": "220904",
          "ctm": "IN01",
          "description": "",
          "host": "sqa",
          "application": "",
          "subApplication": "",
          "outputURI": "https://sqa/automation-api/run/job/IN01:000cj/output",
          "logURI": "https://sqa/automation-api/run/job/IN01:000cj/log"
        },
        {
          "jobId": "IN01:000ck",
          "folderId": "IN01:000cj",
          "numberOfRuns": 1,
          "name": "job_to_modify",
          "folder": "Folder_1/Project_Folder1",
          "type": "Command",
          "status": "Ended Not OK",
          "held": false,
          "deleted": false,
          "cyclic": false,
          "startTime": "Sep 4, 2022, 5:22:49 PM",
          "endTime": "Sep 4, 2022, 5:22:50 PM",
          "estimatedStartTime": [
            "20220904172630"
          ],
          "estimatedEndTime": [
            "20220904173130"
          ],
          "orderDate": "220904",
          "ctm": "IN01",
          "description": "This job was created for editing part of an existing flow - Ended Not OK",
          "host": "sqa",
          "application": "FOLDER_HOLDER",
          "subApplication": "",
          "outputURI": "https://sqa/automation-api/run/job/IN01:000ck/output",
          "logURI": "https://sqa/automation-api/run/job/IN01:000ck/log"
        },
        {
          "jobId": "IN01:000cl",
          "folderId": "IN01:000ci",
          "numberOfRuns": 0,
          "name": "Project_Folder2",
          "folder": "Folder_1",
          "type": "Sub-Table",
          "status": "Ended OK",
          "held": false,
          "deleted": false,
          "cyclic": false,
          "startTime": "Sep 4, 2022, 5:22:49 PM",
          "endTime": "Sep 4, 2022, 5:22:51 PM",
          "orderDate": "220904",
          "ctm": "IN01",
          "description": "",
          "host": "sqa",
          "application": "",
          "subApplication": "",
          "outputURI": "https://sqa/automation-api/run/job/IN01:000cl/output",
          "logURI": "https://sqa/automation-api/run/job/IN01:000cl/log"
        },
        {
          "jobId": "IN01:000cm",
          "folderId": "IN01:000cl",
          "numberOfRuns": 1,
          "name": "job_not_to_touch",
          "folder": "Folder_1/Project_Folder2",
          "type": "Command",
          "status": "Ended OK",
          "held": false,
          "deleted": false,
          "cyclic": false,
          "startTime": "Sep 4, 2022, 5:22:49 PM",
          "endTime": "Sep 4, 2022, 5:22:50 PM",
          "orderDate": "220904",
          "ctm": "IN01",
          "description": "This job was created for editing part of an existing flow - ended ok",
          "host": "sqa",
          "application": "FOLDER_HOLDER",
          "subApplication": "",
          "outputURI": "https://sqa/automation-api/run/job/IN01:000cm/output",
          "logURI": "https://sqa/automation-api/run/job/IN01:000cm/log"
        }
      ],
      "startIndex": 0,
      "itemsPerPage": 25,
      "total": 5
  5. retrieve the definitions of the job_to_modify job and modify its properties using the deploy jobs::get command, as in the following example command and response.

    The PathElement object in the response defines the path to the job or subfolder within the folder on the target server.

    Copy
    > ctm deploy jobs::get -s "ctm=IN01&folder=Folder_1&job=job_to_modify" -e testEnvironment

    {
       "job_to_modify": {
          "Type": "Job:Command",
          "Description": "this job was created to editing part of an existing flow - Ended Not OK",
          "RunAs": "controlm",
          "Application": "FOLDER_HOLDER",
          "Command": "job that need to be modify",
          "PathElement": {
             "Folder": "Folder_1:Project_Folder1",
             "Server": "IN01"
          }
       } 
    }
  6. In modify_single_job.json, correct the erroneous "Command" property, by adding echo at the beginning of the command, as shown in the following example:

    Copy
    {
       "job_to_modify": {
          "Type": "Job:Command",
          "Description": "this job was created to editing part of an existing flow - Ended Not OK",
          "RunAs": "controlm",
          "Application": "FOLDER_HOLDER",
          "Command": "echo job that need to be modify",
          "PathElement": {
             "Folder": "Folder_1:Project_Folder1",
             "Server": "IN01"
          }
       } 
    }
  7. Deploy the job that you modified in the previous step using the deploy command, as shown in the following command and response.

    Copy
    > ctm deploy modify_single_job.json

    [
        {
           "deploymentFile": "modify_single_job.json ",
           "deploymentStatus": "ENDED_OK",
           "successfulFoldersCount": 0,
           "successfulSmartFoldersCount": 0,
           "successfulSubFoldersCount": 0,
           "successfulJobsCount": 1,
           "successfulConnectionProfilesCount": 0,
           "successfulDriversCount": 0,
           "isDeployDescriptorValid": false
        }  
    ]
  8. Run the flow again with the modified job using the run order command, as shown in the following command and response.

    Copy
    > ctm run order IN01 Folder_1

    {
       "runId": "cedeb0cc-82c6-47a4-88b2-0407781089c3",
       "statusURI": "https://sqa/automation-api/run/status/cedeb0cc-82c6-47a4-88b2-0407781089c3"
    }
  9. Retrieve the run status of all elements in the modified job using the run status command, as in the following example command and response.

    Note that the "status" property of the job_to_modify job is returned as "Ended OK".

    Copy
    > ctm run status cedeb0cc-82c6-47a4-88b2-0407781089c3

    {
        "completion": "Completed",
        "statuses": [
           {
              "jobId": "IN01:000ci",
              "folderId": "IN01:",
              "numberOfRuns": 2,
              "name": "Folder_1",
              "folder": "Folder_1",
              "type": "Folder",
              "status": "Ended Not OK",
              "held": false,
              "deleted": false,
              "cyclic": false,
              "startTime": "Sep 4, 2022, 5:49:40 PM",
              "endTime": "Sep 4, 2022, 5:49:42 PM",
              "estimatedStartTime": [
                 "20220904174940"
              ],
              "estimatedEndTime": [
                 "20220904175450"
              ],
              "orderDate": "220904",
              "ctm": "IN01",
              "description": "",
              "host": "sqa",
              "application": "",
              "subApplication": "",
              "outputURI": "Folder has no output",
              "logURI": "https://sqa/automation-api/run/job/IN01:000ci/log"
          },
          {
              "jobId": "IN01:000cr",
              "folderId": "IN01:000ci",
              "numberOfRuns": 0,
              "name": "Project_Folder1",
              "folder": "Folder_1",
              "type": "Sub-Table",
              "status": "Ended OK",
              "held": false,
              "deleted": false,
              "cyclic": false,
              "startTime": "Sep 4, 2022, 5:49:40 PM",
              "endTime": "Sep 4, 2022, 5:49:41 PM",
              "estimatedStartTime": [
                 "20220904174940"
              ],
              "estimatedEndTime": [
                 "20220904175000"
              ],
              "orderDate": "220904",
              "ctm": "IN01",
              "description": "",
              "host": "sqa",
              "application": "",
              "subApplication": "",
              "outputURI": "https://sqa/automation-api/run/job/IN01:000cr/output",
              "logURI": "https://sqa/automation-api/run/job/IN01:000cr/log"
          },
          {
              "jobId": "IN01:000cs",
              "folderId": "IN01:000cr",
              "numberOfRuns": 1,
              "name": "job_to_modify",
              "folder": "Folder_1/Project_Folder1",
              "type": "Command",
              "status": "Ended OK",
              "held": false,
              "deleted": false,
              "cyclic": false,
              "startTime": "Sep 4, 2022, 5:49:40 PM",
              "endTime": "Sep 4, 2022, 5:49:41 PM",
              "orderDate": "220904",
              "ctm": "IN01",
              "description": "This job was created for editing part of an existing flow - ended ok",
              "host": "sqa",
              "application": "FOLDER_HOLDER",
              "subApplication": "",
              "outputURI": "https://sqa/automation-api/run/job/IN01:000cs/output",
              "logURI": "https://sqa/automation-api/run/job/IN01:000cs/log"
          },
          {
              "jobId": "IN01:000ct",
              "folderId": "IN01:000ci",
              "numberOfRuns": 0,
              "name": "Project_Folder2",
              "folder": "Folder_1",
              "type": "Sub-Table",
              "status": "Ended OK",
              "held": false,
              "deleted": false,
              "cyclic": false,
              "startTime": "Sep 4, 2022, 5:49:40 PM",
              "endTime": "Sep 4, 2022, 5:49:41 PM",
              "estimatedStartTime": [
                 "20220904174940"
              ],
              "estimatedEndTime": [
                 "20220904175000"
              ],
              "orderDate": "220904",
              "ctm": "IN01",
              "description": "",
              "host": "sqa",
              "application": "",
              "subApplication": "",
              "outputURI": "https://sqa/automation-api/run/job/IN01:000ct/output",
              "logURI": "https://sqa/automation-api/run/job/IN01:000ct/log"
          },
          {
              "jobId": "IN01:000cu",
              "folderId": "IN01:000ct",
              "numberOfRuns": 1,
              "name": "job_not_to_touch",
              "folder": "Folder_1/Project_Folder2",
              "type": "Command",
              "status": "Ended OK",
              "held": false,
              "deleted": false,
              "cyclic": false,
              "startTime": "Sep 4, 2022, 5:49:40 PM",
              "endTime": "Sep 4, 2022, 5:49:41 PM",
              "orderDate": "220904",
              "ctm": "IN01",
              "description": "This job was created for editing part of an existing flow - ended ok",
              "host": "sqa",
              "application": "FOLDER_HOLDER",
              "subApplication": "",
              "outputURI": "https://sqa/automation-api/run/job/IN01:000cu/output",
              "logURI": "https://sqa/automation-api/run/job/IN01:000cu/log"
          } 
       ],
       "startIndex": 0,
       "itemsPerPage": 25,
       "total": 4
    }