Variable Override Priority
Harness provides builtin and custom variables, as described in What is a Harness Variable Expression?.
You can override a lot of variable values in order to templatize and customize deployment settings.
These overrides have priority. For example, you can override a Service variable in an Environment and a Workflow.
In this topic, we explain how Harness prioritizes variable overrides. Hopefully, this will help you manage your variables more effectively.
In this topic:
- Before You Begin
- Where are Variables Overridden?
- In What Order are Variables Overridden?
- Other Service Configuration Types
- See Also
Before You Begin
Where are Variables Overridden?
Service variables can be overridden in Environments and Workflows.
When you override a Service variable in an Environment, the Service variable can be still be overridden in a Workflow.
Service Configuration Overrides
Service Config variables can be are overridden in an Environment's Service Configuration Overrides section.
Service Configuration Overrides can override all Service Config variables, or the Service Config variables in specific Services.
Overriding Service Variables in Workflows
There two ways to override Service variables in a Workflow:
Use Workflow Variables in the Service Settings
The most effective method for overriding Service settings in a Workflow, is to create a Workflow variable and then use its expression in the Service setting.
When you deploy the Workflow, you are prompted to supply a value for the Workflow variable. The value you provide is then used in the Service setting at deployment runtime.
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:
Use Service Variable Overrides in a Workflow Phase
Each Phase of a multi-phase Workflow, such as a Canary Workflow, allows you to override the Service variables for the Service the Workflow Phase deploys:
In What Order are Variables Overridden?
Here is how Harness prioritizes variables, from highest to least priority:
- Highest: Workflow variable or Workflow Phase. See Set Workflow Variables.
Pipelines—If the Workflow is executed by a Pipeline, the value provided for the Workflow variable in the Pipeline has the highest priority.
- Next: Environment Service Configuration Overrides. See Override a Service Configuration in an Environment.
- Last: Service Config Variables. See Add Service Config Variables.
Other Service Configuration Types
Some Service types support other Configuration types, such as
- ConfigMap YAML — See Override Harness Kubernetes Service Settings.
- Values YAML — See Override Values YAML Files and Override Variables at the Infrastructure Definition Level.
- Service Configuration Files — See Override a Service Configuration in an Environment.