PCF Built-in Variables

Updated 1 month ago by Chakravarthy Tenneti

Harness includes the following variables to help you output PCF deployment information in your Workflows, such as in the CF Command or the Shell Script command.

In Blue/Green deployments, the outputs for the ${pcf.finalRoutes} and ${pcf.tempRoutes} variables do not change, but the outputs for ${pcf.newAppRoutes} and ${pcf.oldAppRoutes} change as the routes are swapped in the Swap Routes or Rollback step. Simply put, ${pcf.newAppRoutes} and ${pcf.oldAppRoutes} reflect the routes at a point in time (before or after the Swap Routes or Rollback step).

Variable

Description

${service.manifest}

Refers to the folder containing your manifest files. See Scripts and Variables.

${service.manifest.repoRoot}

Refers to the remote Git repo root folder containing your manifest files. See Scripts and Variables.

${pcf.newAppRoutes}

An array of all the routes defined in your manifest.yml in your Harness Service.

You can reference any route in the array using its index, such as ${pcf.newAppRoutes[0]}.

You can use the route to create a URL in a script, such as http://${pcf.newAppRoutes[0]}.

In a Blue/Green deployment, ${pcf.newAppRoutes} are the same as ${pcf.tempRoutes} until the Swap Routes step is run, after which ${pcf.newAppRoutes} is the same as ${pcf.finalRoutes}.

${pcf.newAppName}

New app name.

${pcf.newAppGuid}

New app GUID.

${pcf.oldAppName}

Old app name. This is the app that is replaced by your newly deployed app.

${pcf.oldAppGuid}

Old app GUID.

${pcf.oldAppRoutes}

An array of the routes that were used for the old app.

You can reference any route in the array using its index, such as ${pcf.oldAppRoutes[0]}.

You can use the route to create a URL in a script, such as http://${pcf.oldAppRoutes[0]}.

${pcf.finalRoutes}

An array of the active routes once deployment is successful.

${pcf.tempRoutes}

An array of the temporary routes used for Blue/Green deployments.

${infra.pcf.cloudProvider.name}

The Cloud Provider name used in the Infrastructure Definition set up in the Workflow.

${infra.pcf.organization}

The Organization name used in the Infrastructure Definition set up in the Workflow.

${infra.pcf.space}

The Space name used in the Infrastructure Definition set up in the Workflow.

${host.pcfElement.applicationId}

Shows the PCF app ID Environment variable. Such as you would see in a cf env command:

...
{
"VCAP_APPLICATION": {
"application_id": "fa05c1a9-0fc1-4fbd-bae1-139850dec7a3",
"application_name": "my-app",
...

${host.pcfElement.displayName}

Shows the PCF app name ("application_name": "my-app" in the example above).

${host.pcfElement.instanceIndex}

Shows the CF_INSTANCE_INDEX.

Here is a script that outputs some of the variables:

echo ${pcf.newAppRoutes[0]}

echo New App Name: ${pcf.newAppName}
echo New App Guild: ${pcf.newAppGuid}
echo New App Routes: ${pcf.newAppRoutes}

echo "\n\n"
echo Old App Name: ${pcf.oldAppName}
echo Old App Guild: ${pcf.oldAppGuid}
echo Old App Routes: ${pcf.oldAppRoutes}

echo activeRoute: ${pcf.finalRoutes}
echo inActiveRoute: ${pcf.tempRoutes}

echo ${infra.pcf.cloudProvider.name}
echo ${infra.pcf.organization}
echo ${infra.pcf.space}

Harness PCF Environment Variables

For Blue/Green Workflow deployments only, Harness uses the PCF user-provided environment variable HARNESS_STATUS_IDENTIFIER to identify new and old (active) apps.

When a new app is deployed, the variable is HARNESS_STATUS_IDENTIFIER : STAGE.

When Harness swaps route, the variable is updated to HARNESS_STATUS_IDENTIFIER : ACTIVE for the new app, and the old app variable becomes HARNESS_STATUS_IDENTIFIER : STAGE.

If rollback occurs, Harness restores routes and environment variables for old and new apps.

You can view this HARNESS_STATUS_IDENTIFIER variable in the PCF app in the PCF console.


How did we do?