Unpacking variables in skip condition

Introduction

In this article we will discuss about how we can can setup a skip condition that is concatenation of two or more variables.

Considering you need to setup an skip condition that references combination of two variable as given below:

Skip condition :

${serviceVariable.SkipVar}!="NONE"

Values in service variables :

SkipVar={service.name}.${serviceVariable.Var1}

How does Harness Evaluates the given Expression and skip the pipeline based on given expression?

SkipVar=${service.name}.${serviceVariable.Var1} β€œ.” in expression evaluation in skip condition will cause issues.

Error message :

Error evaluating skip condition: ${serviceVariable.Var1}!="NONE": Variable:
[[email protected]:1](mailto:[email protected]:1) undefined variable Var1.VAR_6130

The issue here is the way in which the above vars are evaluated by JEXL. In some rare cases, it can work but it’s recommended to use β€œ.” with a β€œ+” operator to ensure that they are evaluated correctly.

${service.name}+ "." +${serviceVariable.var1}

Taking the above point into account, the recommended way here would be to use the format as mentioned below so the JEXL evaluation is as expected.

You can find the details on setting up skip conditions here:

  1. Skip workflow steps: Skip Workflow Steps - Harness.io Docs
  2. Pipeline skip conditions: Pipeline Skip Conditions - Harness.io Docs
3 Likes