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. Prepare initial deployment

As we know, a typical deployment starts with an Initial Deployment in the Digital.ai Deploy GUI.

This is where you drag & drop your package and the environment to where you want to deploy to.

So, the first step will be to make a REST API call to prepare the initial deployment using the Environment & the Application package version:

curl -u admin:<password> -X GET "http://localhost:4516/xldeploy/deployment/prepare/initial?environment=Environments/<environment>&version=Applications/<application>/<package version>" > task.xml

It will produce the file task.xml with the contents similar to the below:

<deployment id="5560e1e4-9eaf-4131-8fce-bb74f5b86798" type="INITIAL">
<deploymentGroupIndex>0</deploymentGroupIndex>
<application>
<udm.DeployedApplication id="Environments/Localhost/CMD">
<version ref="Applications/CMD/1.0"/>
<environment ref="Environments/Localhost"/>
<deployeds/>
<orchestrator/>
<optimizePlan>true</optimizePlan>
<boundConfigurationItems/>
<unresolvedPlaceholders/>
<undeployDependencies>false</undeployDependencies>
<forceRedeploy>false</forceRedeploy>
<allowConcurrentDeployments>true</allowConcurrentDeployments>
</udm.DeployedApplication>
</application>
<deployeds/>
<deployables>
<ci ref="Applications/CMD/1.0/CMD" type="cmd.Command"/>
</deployables>
<containers>
<ci ref="Infrastructure/Localhost" type="overthere.LocalHost"/>
</containers>
<resolvedPlaceholders/>
<requiredDeployments/>
</deployment>

...which is saved to the task.xml file.

We will require this file in the next call.

 

2. Prepare Deployeds

Now we need to prepare the deployeds for our deployment.

Make the API call using the task.xml file produced in Step 1, as the payload:

curl -u admin:<password> -H "content-type:application/xml" -X POST "http://localhost:4516/deployit/deployment/prepare/deployeds" -d @task.xml > prepare.xml

It will produce the file prepare.xml with the contents similar to the below:

<deployment id="deployment-cb799c52-2567-425d-8ace-0096a9f1f81f" type="INITIAL">
<deployment id="5560e1e4-9eaf-4131-8fce-bb74f5b86798" type="INITIAL">
<deploymentGroupIndex>0</deploymentGroupIndex>
<application>
<udm.DeployedApplication id="Environments/Localhost/CMD">
<version ref="Applications/CMD/1.0"/>
<environment ref="Environments/Localhost"/>
<deployeds/>
<orchestrator/>
<optimizePlan>true</optimizePlan>
<boundConfigurationItems/>
<unresolvedPlaceholders/>
<undeployDependencies>false</undeployDependencies>
<forceRedeploy>false</forceRedeploy>
<allowConcurrentDeployments>true</allowConcurrentDeployments>
</udm.DeployedApplication>
</application>
<deployeds>
<cmd.DeployedCommand id="Infrastructure/Localhost/CMD">
<deployable ref="Applications/CMD/1.0/CMD"/>
<container ref="Infrastructure/Localhost"/>
<order>50</order>
<dependencies/>
<commandLine>ping -c 5 google.com</commandLine>
<undoOrder>49</undoOrder>
<undoDependencies/>
<runUndoCommandOnUpgrade>true</runUndoCommandOnUpgrade>
<rerunCommand>false</rerunCommand>
</cmd.DeployedCommand>
</deployeds>
<deployables>
<ci ref="Applications/CMD/1.0/CMD" type="cmd.Command"/>
</deployables>
<containers>
<ci ref="Infrastructure/Localhost" type="overthere.LocalHost"/>
</containers>
<resolvedPlaceholders/>
<requiredDeployments/>
</deployment>

 

3. Validate the deployment

We will now make the REST API to validate the deployment.

Make the API call using the task.xml file produced in Step 1, as the payload:

curl -u admin:<password> -H "content-type:application/xml" -X POST "http://localhost:4516/deployit/deployment/validate" -d @task.xml

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

 

4. Initiate the deployment

This step initiates the deployment.

Make the API call using the prepare.xml file produced in Step 2, as the payload:

curl -u admin:<password> -H "content-type:application/xml" -X POST "http://localhost:4516/deployit/deployment" -d @prepare.xml

The call will produce a Deployment ID, as shown in the output below

5560e1e4-9eaf-4131-8fce-bb74f5b86798

 

5. Start the deployment

This step starts the deployment.

Make the API call using the Deployment ID produced in Step 4:

curl -u admin:<password> -H "content-type:application/xml" -X POST "http://localhost:4516/deployit/task/<deployment id>/start"

 

6. Archive the deployment

This step archives the deployment.

Make the API call using the Deployment ID produced in Step 4:

curl -u admin:<password> -H "content-type:application/xml" -X POST "http://localhost:4516/deployit/task/<deployment id>/archive"

 

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

Comments

0 comments

Please sign in to leave a comment.