You can use the Cloud Foundry Server task to model a pipeline task connecting to the target Cloud Foundry server instance to 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. Select Cloud Foundry from the Provider drop-down menu.
  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 an Execute Task for 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 using the following operands and operators is supported.

    • Pipeline variables such as, ${pipeline.variableName}. Curly brackets are reserved for specifying 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 is 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 available 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. The route is deleted if it is not linked to any other application.

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

    3. Select Deploy Application > Properties.

      Option

      Description

      Manifest URL

      Enter the manifest file URL and click on the Basic Auth link to authenticate the repository containing the manifest file.

      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.

      Click on the Basic Auth link to authenticate the repository containing the downloadable artifactory.

      You can also deploy an application with advanced options where you can perform the following actions:

      • 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.

      Clean up on failure

      Select the check box if you want to delete the application from the Cloud Foundry server when the application deployment fails.

      You can view the name, URL and the status of the application you have 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 provide variable binding to read from the pipeline or task property. 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 the status of the application you have 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 you have selected from the Output tab.

      You can select Stop an Application to stop an application and choose to read from the pipeline/task property or select an existing application.

  12. Click Save.

Task Output Format for a Cloud Foundry Server

The following task output format is an example for a Cloud Foundry Server task to scale, bind, unbind, stop, start, and delete an application. The output contains status of only 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 task output format is an example for a Cloud Foundry Server task to deploy an application. The output contains 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"
      }
    }
  }
]