When you use a cloud template task in Code Stream, a common question is how to use the output of that task in a subsequent task in your pipeline. To use the output of a cloud template task, such as a cloud machine, you must know how to find the resource properties in the deployment details of the cloud template task, and the IP address of the cloud machine.

For example, the deployment details of a VMware Cloud Template include the cloud machine resource and its IP address. In your pipeline, you can use the cloud machine and IP address as a variable to bind a cloud template task to a REST task.

The method that you use to find the IP address for the cloud machine is not typical, because the deployment of the VMware Cloud Template must finish before the deployment details are available. Then, you can use the resources from the VMware Cloud Template deployment to bind your pipeline tasks.

  • The resource properties that appear in a cloud template task in your pipeline are defined in the VMware Cloud Template in Cloud Assembly.
  • You might not know when a deployment of that cloud template finished.
  • A cloud template task in Code Stream can only display the output properties of the VMware Cloud Template after the deployment finished.

This example can be especially useful if you are deploying an application and invoking various APIs. For example, if you use a cloud template task that calls a VMware Cloud Template, which deploys a Wordpress application with a REST API, you can locate the IP address of the deployed machine in the deployment details, and use the API to test it.

The cloud template task supports you to use variable binding by displaying the type ahead auto fill details. It is up to you how you bind the variable.

This example shows you how to:

  • Find the deployment details and resource properties for your cloud template task in a pipeline that ran and succeeded.
  • Find the cloud machine IP address in the resources section of the deployment details.
  • Add a REST task subsequent to the cloud template task in your pipeline.
  • Bind the cloud template task to the REST task by using the cloud machine IP address in the URL of the REST task.
  • Run your pipeline and watch the binding work from the cloud template task to the REST task.

Prerequisites

  • Verify that you have a working VMware Cloud Template that is versioned.
  • Verify that the deployment of the VMware Cloud Template succeeded in Cloud Assembly.
  • Verify that you have a pipeline that includes a cloud template task that uses that VMware Cloud Template.
  • Verify that your pipeline ran and succeeded.

Procedure

  1. In your pipeline, locate the IP address of the cloud machine in the resources section of your cloud template task deployment details.
    1. Click Actions > View executions.
    2. In a pipeline run that succeeded, click the link to the pipeline execution.
      The pipeline execution displays the completion status and includes a link to the pipeline run.
    3. Under the pipeline name, click the link to the Task.
      From the pipeline execution, you can click the link to the task and see the details.
    4. In the Output area, locate the Deployment details.
      In the pipeline task details, the output area displays the details and a link to the deployment.
    5. In the resources section of the deployment details, locate the cloud machine name.
      You will include the syntax for the cloud machine name in the URL of your REST task.
    6. To find the binding expression for the output property of the cloud template task, click VIEW OUTPUT JSON, search for the address property, and locate the cloud machine IP address.
      The binding expression appears below the property and search icon in the JSON output.
      To search for an expression, such as a cloud machine address, you can use the path finder at the bottom of the task details.
      The address resource property displays the cloud machine IP address. For example:
      "resources": {
      		"Cloud_Machine_1[0]": {
      			"name": "Cloud_Machine_1[0]",
      			"powerState": "ON",
      			"address": "10.108.79.51",
      			"resourceName": "Cloud_Machine_1-mcm187515-152919380820"
  2. Return to your pipeline model, and enter the URL in your REST task.
    1. Click Actions > View Pipeline.
    2. Click the REST task.
    3. In the REST Request URL area, enter $, select the Stage, Task, output, deploymentDetails, and enter resources.
      The ability to type ahead with auto fill is available up to the point that you must enter resources.
    4. Enter the rest of the cloud machine resource from the deployment details as: {'Cloud_Machine_1[0]'].address}
      In the REST task, you can enter the expression for the cloud machine address.
      For the cloud machine entry, you must use the square bracket notation as shown.
    The complete URL format is: ${Stage0.Task0.output.deploymentDetails.resources{'Cloud_Machine_1[0]'].address}
  3. Run your pipeline and watch the REST task use the cloud machine and IP address from the output of your cloud template task as the URL to test.

Results

Congratulations! You found the cloud machine name and IP address in the deployment details and JSON output of a cloud template task, and used them to bind your cloud template task output to your REST task URL input in your pipeline.

What to do next

Continue to explore using binding variables from resources in the cloud template task with other tasks in your pipeline.