Use Expressions for the DB Schema Git Connector
Set the DB Schema Git connector, repository, schema file path, and archive path from a pipeline expression or runtime input.
On a database schema that uses a Harness connector as the changelog source, you can set source fields to a fixed value, a pipeline expression, or a runtime input. Harness resolves those values when the pipeline runs and uses them to clone the changelog.
Use this when environments need different Git connectors, repositories, or changelog paths, without editing the schema before every run. Every Database DevOps step that uses the schema honors these expressions, including Apply DB Schema, Rollback DB Schema, Update SQL, Rollback SQL, Liquibase Command, Flyway Command, and DB Test and Preview.
Before you begin
DB Schema with Connector: A database schema with Connector selected under How do you want to connect to your data schema?.
Database DevOps pipeline: A pipeline that can supply the variables or runtime inputs. Go to Create a pipeline in Database DevOps to create one.
Supported fields
If a field shows Convert to expression in the UI, you can set it to an expression or a runtime input.
Connector
Yes
Yes
Repository
Yes
Yes
Path to Schema File
Yes
Yes
Archive path (Artifactory)
Yes
Yes

Supported expression forms
The following forms are supported on fields that allow expressions:
Pipeline variable
<+pipeline.variables.connector_name>
Stage variable
<+stage.variables.connector_name>
Runtime input
<+input>
Runtime input with default
<+input>.default(my-git-connector)
Runtime input with allowed values
<+input>.allowedValues(dev-git,prod-git)
Configure the schema and pipeline
Add pipeline variables
Open your Database DevOps pipeline, and then click Variables.
Under Custom Variables, add variables for the values you want to resolve at runtime. For example:
connector_name: The Git connector identifier.
repo_name: The repository name.
You can leave a value empty and supply it as a runtime input when you run the pipeline.

Set expressions on the DB Schema
To configure the schema connection fields, perform the following:
In Database DevOps, click DB Schemas.
Next to the schema, click (⋮), then select Edit.
Under How do you want to connect to your data schema?, select Connector.
In Connector, enter an expression such as
<+pipeline.variables.connector_name>, or select Convert to expression.In Repository, enter a fixed repository name, or an expression such as
<+pipeline.variables.repo_name>.In Path to Schema File, enter a fixed path (for example,
sample.changelog.yaml), or an expression.If you use an Artifactory connector, enter a fixed path or an expression in Archive path.
Click Save.
Examples
Different Git connector per environment
Set the schema Connector to:
Keep Repository and Path to Schema File fixed if only the connector changes between environments.
In each stage, set connector_name to the connector that can reach that environment's Git host.
Connector and repository from variables
Set both fields on the schema:
Provide both values as pipeline variables, or as runtime inputs when you run the pipeline.
Next steps
Create a pipeline in Database DevOps: Build the pipeline that supplies the variables.
Apply DB Schema step: Deploy the schema after the expressions resolve.
Last updated
Was this helpful?