Using Variables in Workflow Approvals

Updated 1 week ago by Archana Singh

You can add predefined or user-defined variables in a Workflow Approval step. When the Workflow is deployed, these variables become available as inputs for logging and auditing and can be overwritten by approvers.

The available approval mechanisms are:

Before You Begin

Step 1: Add an Approval Step in a Workflow

  1. In your Workflow, click Add Step.
  2. Select Approval. You can search or click Flow Control and select Approval.
  3. Click Next.
    The Add Step settings appear.
  4. In Configure Approval, enter Name.
  5. Select Harness UI in the Ticketing System.
    You can use Jira Service Desk, ServiceNow, and Custom Shell Script based approvals as well. For more information on how to add these approvals, see Jira Approvals, ServiceNow Approvals, and Custom Shell Script Approvals.
  6. Select one or more User Group(s) to notify for the approval requests.
  7. Enter the time duration that Harness should wait for the approval or rejection before killing the deployment process. You can use w  for week, d  for day, h  for hour, m  for minutes, s  for seconds and ms for milliseconds. For example, 1d for one day.
  8. Click Advanced Settings to set the additional settings.
  9. Click Add Variable to define variables. To define a new variable, enter a Name and a Default Value. You can use this variable combined with its parent variable name to reference the variable elsewhere.
  10. In Publish Variable Name, enter a parent name for the collection of subordinate variables that you can reference with its child variables (as you defined in the previous step). This parent name helps to avoid conflicts when there are subordinate variables of the same name within the same scope.
  11. Set the Scope for the variables that you defined in the previous step. You can choose, Phase, Workflow, or Pipeline.
  12. Click Submit to save this Approval step, along with its variables.

Step 2: Approve Workflows

Workflow uses the Approval variables as defined in the Add an Approval Step in a Workflow option, when it deploys. Deployment pauses at the Approval step.

  1. Click Approval step.
    A user (in one of the User Groups configured as approvers) can click the Approval step. The Needs Approval settings appear.
  2. Enter your comments, and click Approve.

Once this step is approved, the Workflow can continue deployment.

How did we do?