Use the Cloud Foundry task to model a pipeline task that connects to a Cloud Foundry instance. The task can deploy, scale, start, stop, and delete an application. You can also bind and unbind services to an application.

Prerequisites

  • Verify that the Cloud Foundry Server endpoint is registered. See the Installation and Configuration Guide.

Procedure

  1. Click the Code Stream tab.
  2. On the Pipelines tab, select an existing pipeline, and click Edit to configure it.
  3. Click the Stages > button.
  4. Click Add Task.
  5. From the Provider drop-down menu, select Cloud Foundry.
  6. Enter a name for the task, and click OK.
  7. Select the new task in the stage.
  8. Confirm to save the pipeline.
  9. Select when to run the task in the release pipeline.

    Option

    Description

    Always

    Runs the release pipeline task without conditions.

    On Condition(s)

    Runs the release pipeline task only if the defined condition is evaluated as true. If the condition is false, the task is skipped.

    A boolean expression, which uses the following operands and operators, is supported.

    • Pipeline variables such as, ${pipeline.variableName}. Curly brackets are reserved for entering pipeline variables.

    • Task output variables such as, ${Stage1.task1.machines[0].value.hostIp[0]}

    • Default pipeline binding variables such as, ${releasePipelineName}

    • Case insensitive Boolean values such as, true, false, 'true', 'false'

    • Integer or decimal values without quotes

    • String values used with single or double quotes such as, "test", 'test'

    • String and Numeric types of values such as, == Equals and != Not Equals

    • Relational operators such as, >, >=, <, and <=

    • Boolean logic such as, && and ||

    • Arithmetic operators such as, +, -, *, and /

    • Nested expressions using round brackets

    • Strings with literal value ABCD are evaluated as false and the task is skipped.

    Unary operators are not supported.

    A sample condition, ${Stage1.task1.output} == “Passed” || ${pipeline.variableName} == 39

  10. (Optional) Select the Continue Pipeline execution even if this task fails option.

    This option allows the release pipeline to bypass the failed task and continue with the execution process.

  11. Enter the Cloud Foundry properties.

    Option

    Description

    Endpoint

    Provides a list of registered endpoints for Cloud Foundry.

    Organization

    Lists the existing organizations.

    Space

    Lists the spaces in the selected organization.

    Action

    Lists the tasks such as deploy, scale, start, stop, delete an application in a Cloud Foundry instance.

    1. Select Bind/Unbind Services > Properties.

      Option

      Description

      Read from Pipeline/Task property

      Enter the name of the application or provide variable binding to read from the pipeline or task property.

      Existing Applications

      Select an existing application.

      You can view the name, URL, and the status of the application you have selected from the Output tab.

    2. Select Delete an Application > Properties.

      Option

      Description

      Read from Pipeline/Task property

      Enter the name of the application.

      Existing Applications

      Select the name of an existing application.

      Delete Route

      Delete the path or route associated with the application. If the route is not linked to any other application, it is deleted.

      You can view the name, URL, and status of the application that you selected from the Output tab.

    3. Select Deploy Application > Properties.

      Option

      Description

      Manifest URL

      To authenticate the repository that contains the manifest file, enter the manifest file URL, and click the Basic Auth link.

      Note:

      Authenticate the URL if you download the artifact from hosting servers such as an Artifactory server.

      User Defined

      Enter the application name, click Add, and enter the configurable properties such as disk and memory information, and the number of instances of the application.

      Enter the Artifact URL, which is the path where the application is located in the repository. For example: http://artifactoryserver.com/artifactory/deb-local/SampleArtifactory.war.

      To authenticate the repository that contains the downloadable artifact, click the Basic Auth link.

      You can also deploy an application by using advanced options where you:

      • Provide the domain name.

      • Select services.

      • Select the stack.

      • Enter a command. For example: bundle exec rake VERBOSE=true.

      • Enter the host URL. For example: http://sample-host.domain.

      • Enter the buildpack URL. For example: https://github.com/cloudfoundry/java-buildpack.git.

      Start Applications

      To start the applications on the Cloud Foundry instance after deployment, select the check box.

      Clean up on failure

      To delete the application from the Cloud Foundry instance when the application deployment fails, select the check box.

      You can view the name, URL, and status of the application that you selected from the Output tab.

    4. Select Scale an Application > Properties.

      Option

      Description

      Read from Pipeline/Task property

      Enter the name of the application. Or, to read from the pipeline or task property, provide variable binding. Enter the memory and disk size. Enter the number of instances of the application.

      Existing Applications

      Select the name of an existing application, enter the disk and memory information, and number of instances of the application.

      Note:

      You can view information about the memory, disk, and the number of instances from a pipeline or task property.

      You can view the name, URL, and status of the application that you selected from the Output tab.

    5. Select Start an Application > Properties.

      Option

      Description

      Read from Pipeline/Task property

      Enter the name of the application, or provide variable binding to read from the pipeline or task property.

      Existing Applications

      Select the name of an existing application.

      You can view the name, URL, and the status of the application that you selected from the Output tab.

      To stop an application, and select to read from the pipeline/task property or select an existing application, select Stop an Application.

  12. Click Save.

Task Output Format for a Cloud Foundry Instance

The following output format is an example for a Cloud Foundry task that is used to scale, bind, unbind, stop, start, and delete an application. The output contains the status of one application.

[
  {
    "name": "detailedStatus",
    "type": "JSON",
    "value": {
      " sample-iot-app": {
        "status": "SUCCESS",
        "displayStatus": "Success",
        "appName": " sample-iot-app",
        "appUrl": "sample-iot-app.cf.vca10.pivotal.io",
      }
    }
  }
]

The following output format is an example for a Cloud Foundry task that is used to deploy an application. The output contains the status of more than one application.

[
  {
    "name": "detailedStatus",
    "type": "JSON",
    "value": {
      "sample-iot-app": {
        "status": "SUCCESS",
        "displayStatus": "Success",
        "appName": "sample-iot-app",
        "appUrl": "sample-iot-app.cf.vca10.pivotal.io"
      },
      "sample-schedule-app": {
        "status": " SUCCESS ",
        "displayStatus": " Success ",
        "appName": "sample-schedule-app",
        "appUrl": " sample-schedule-app.cf.vca10.pivotal.io"
      }
    }
  }
]