Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.
Harness DB DevOpsPipeline ExpressionsGit Connectordb schema

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.

Field
Fixed value
Expression or runtime input

Connector

Yes

Yes

Repository

Yes

Yes

Path to Schema File

Yes

Yes

Archive path (Artifactory)

Yes

Yes

Edit Database Schema with Connector and Repository set to pipeline variable expressions

Account-type and repository-type Git connectors

If the resolved connector is a repository-type Git connector, Harness clones that repository. If it is an account-type Git connector, set Repository (fixed value or expression) to the repository to clone. In both cases, Path to Schema File still comes from the schema.


Supported expression forms

The following forms are supported on fields that allow expressions:

Form
Example

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

1

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.

Pipeline custom variables for connector_name and repo_name
2

Set expressions on the DB Schema

To configure the schema connection fields, perform the following:

  1. In Database DevOps, click DB Schemas.

  2. Next to the schema, click (⋮), then select Edit.

  3. Under How do you want to connect to your data schema?, select Connector.

  4. In Connector, enter an expression such as <+pipeline.variables.connector_name>, or select Convert to expression.

  5. In Repository, enter a fixed repository name, or an expression such as <+pipeline.variables.repo_name>.

  6. In Path to Schema File, enter a fixed path (for example, sample.changelog.yaml), or an expression.

  7. If you use an Artifactory connector, enter a fixed path or an expression in Archive path.

  8. Click Save.

3

Run a step that uses the schema

Add or open any Database DevOps step that uses this schema, then run the pipeline.

Harness resolves the expressions, clones the changelog with the resolved Git connector and repository, and continues the step.


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

Last updated

Was this helpful?