Set Workflow Variables

Updated 3 weeks ago by Archana Singh

You can set variables in the Workflow Variables section of your Workflow, and use them in the Workflow step commands and settings.

New to Harness Variables? See What is a Harness Variable Expression?

You can also use them in some Harness Service settings in order to have their values replaced at the Workflow level.

You provide values for Workflow variables at deployment runtime for the Workflow or a Pipeline executing the Workflow.

In this topic:

Before You Begin

Review: Variable Types

There are several different types of Workflow variables you can add:

  • Entity—If you have parameterized a Workflow Service, Environment, or Infrastructure Definition setting, it will appear in Workflow Variables with the type ENTITY. See Templatize a Workflow.
  • Text—A text-based variable.
  • Email—Email addresses.
  • Number—Numeric variable.

Step: Add Workflow Variables

To use Workflow variables, do the following:

  1. In a Workflow, click the pencil icon next to Workflow Variables. The Workflow Variables dialog appears.

Workflow Variables have the following settings.

Field

Description

Variable Name

Enter a name for the variable. When the variable is referenced elsewhere in you Harness application, the variable name is used.

Type

Select Text, Email, or Number.

If you have parameterized a Workflow Service, Environment, or Infrastructure Definition setting, it will appear in Workflow Variables with the type ENTITY.

Allowed Values

Enter a comma-separated list of values that users can select. The list will appear as a drop-down menu when the Workflow is deployed.

Default Value

Enter a value for the variable. A value is not mandatory.

Required

Select this option to enforce that a value for the variable is provided before the Workflow is executed.

Fixed

Select this option if the value of the variable specified here must not be changed.

Description

Provide a description of the variable that lets others know its purpose and requirements.

  1. In a Workflow step, use your variable by typing a dollar sign ($) and the first letter of your variable. The syntax for variable names is ${workflow.variables.name}.

Harness will load matching variable names.

For example, if you created a variable named Url, the variable name is ${workflow.variables.Url}.

When you deploy the Workflow, by itself or as part of a Pipeline, the variables are displayed in the Workflow execution step.

If the variables require values, you will enter the values when you add the Workflow to a Pipeline in the Stage settings or in the New Deployment setting when you deploy the Workflow individually.

Notes

Workflow variable expressions in Services — You can use Workflow variable expressions in a Harness Service, but Harness does not autocomplete Workflow variables in a Service like it does in a Workflow. You will need to manually enter the Workflow variable expression in the Service: ${workflow.variables.name}.

Next Steps


How did we do?