How to: Perform a Complete Deployment from Beginning to end via Digital.ai Deploy using REST API

Scenario

You are trying to automate the deployment process and wish to perform all the deployment steps using REST API calls only without using the GUI.

Environment

Digital.ai Deploy, REST API

Steps to Follow

1. Gather information about Environment and Application version

As we know, a typical deployment starts with an Initial Deployment window in the Digital.ai Deploy GUI. This is where you drag & drop your package and the environment where you want to deploy to.

So, the first step will be to tell REST API about the Environment & the Application version. For this, run a GET call against this:

http://localhost:4516/deployit/deployment/prepare/initial?environment=Environments/
LocalHost&version=Applications/fileApp/1.0

You can see that the Environment here is LocalHost and we are deploying an Application version called Applications/fileApp/1.0.

It will produce output similar to the example below

Note

Make sure you copy this output because we will need it in subsequent steps

<deployment id="deployment-cb799c52-2567-425d-8ace-0096a9f1f81f" type="INITIAL">
<deploymentGroupIndex>0</deploymentGroupIndex>
<application>
<udm.DeployedApplication id="Environments/LocalHost/fileApp">
<version ref="Applications/fileApp/1.0"/>
<environment ref="Environments/LocalHost"/>
<deployeds/>
<orchestrator/>
<optimizePlan>true</optimizePlan>
<boundConfigurationItems/>
<unresolvedPlaceholders/>
<undeployDependencies>false</undeployDependencies>
</udm.DeployedApplication>
</application>
<deployeds/>
<deployables>
<ci ref="Applications/fileApp/1.0/FileApp" type="file.File"/>
</deployables>
<containers>
<ci ref="Infrastructure/LocalHost" type="overthere.LocalHost"/>
</containers>
<requiredDeployments/>
</deployment>

2. Map the Application to the specific container

The next step in GUI is to map the Application to the specific container. Digital.ai Deploy does it automatically now, but we need to tell REST API about this.

For this, run the POST call below by selecting content-type as Application/XML and send the payload you copied in Step 1.

The payload will produce output similar to the example below:

<previewblock id="deployment-78f18844-9106-4637-80de-54e61cdde8f9">
<block id="0" state="PENDING" description="" hasSteps="true" root="true">
<block id="0_1" state="PENDING" description="" hasSteps="true" phase="true">
<block id="0_1_1" state="PENDING" description="Register changes for fileApp" hasSteps="true"
current="0">
<step failures="0" state="PENDING" skippable="false">
<description>Register deployeds</description>
<log></log>
<metadata>
<rule/>
<previewAvailable>false</previewAvailable>
<order>100</order>
</metadata>
</step>
</block>
</block>
</block>
</previewblock>

3. Prepare Deployeds

Now we need to prepare the deployeds for our deployment. Here we are telling REST API it must prepare the deployeds with all the properties they may have. For example, resolve the dictionary (as you can see in the example below) or checking the TargetPath.

Run the POST call below and send the payload you copied in Step 1.

http://localhost:4516/deployit/deployment/prepare/deployeds

It will produce output similar to the example below:

Note

Make sure you copy this output because we will need it in Step 5

<deployment id="deployment-cb799c52-2567-425d-8ace-0096a9f1f81f" type="INITIAL">
<deploymentGroupIndex>0</deploymentGroupIndex>
<application>
<udm.DeployedApplication id="Environments/LocalHost/fileApp">
<version ref="Applications/fileApp/1.0"/>
<environment ref="Environments/LocalHost"/>
<deployeds/>
<orchestrator/>
<optimizePlan>true</optimizePlan>
<boundConfigurationItems/>
<unresolvedPlaceholders/>
<undeployDependencies>false</undeployDependencies>
</udm.DeployedApplication>
</application>
<deployeds>
<file.DeployedFile id="Infrastructure/LocalHost/FileApp">
<deployable ref="Applications/fileApp/1.0/FileApp"/>
<container ref="Infrastructure/LocalHost"/>
<placeholders/>
<targetPath>/tmp</targetPath>
<targetPathShared>true</targetPathShared>
<createTargetPath>false</createTargetPath>
</file.DeployedFile>
</deployeds>
<deployables>
<ci ref="Applications/fileApp/1.0/FileApp" type="file.File"/>
</deployables>
<containers>
<ci ref="Infrastructure/LocalHost" type="overthere.LocalHost"/>
</containers>
<requiredDeployments/>
</deployment>

You can see in output above that out Placeholder was resolved and TargetPath was substituted with value /tmp.

4. Validate the deployment

We will now ask the REST API to validate the deployment. For this run POST call below and send the payload you copied in Step 1.

http://localhost:4516/deployit/deployment/validate

The output from this call will be similar to the payload sent.

5. Execute deployment

This is the last step and here the payload being sent will be the one that has complete deployment information like Placeholders and other properties.

Run the POST call below by supplying the output/payload copied from Step 3.

http://localhost:4516/deployit/deployment/

The call will complete the deployment and give you a Deployment ID, as shown in the output below

cddbc988-934a-4893-b62d-e964799a75f9

You can see this in the Task Monitor of the Digital.ai Deploy GUI. This ID can then be started using TaskService.

Note

All steps (except Step 1) require content-type as Application/XML. SMake sure you select this in your REST client or as a parameter in -X if you are using a cURL command.

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.