Use Custom Script for Harness Database DevOps
Learn how to use a custom script to retrieve and manage a Liquibase changelog in Harness Database DevOps, including DB Schema setup and pipeline configuration.
In certain Database DevOps workflows, users may prefer or require a custom script to retrieve and manage their Liquibase changelog rather than using a connector or direct integration.
This guide provides a comprehensive overview of how to use a custom script for Database DevOps, including the creation of a DB Schema, deployment of the schema, and the use of pipeline variables.
Use case
This guide supports the following scenario:
The customer maintains a Liquibase changelog in a remote repository (for example, GitHub or JFrog). This is particularly useful when the changelog is stored in a repository for which Harness does not provide a native connector.
They want to download and extract this changelog dynamically via a custom shell script.
The script can reference pipeline variables, such as build versions or access tokens.
Deploy using a custom script
By following these steps, you can effectively manage your database changes and streamline your DevOps processes.
Create a DB schema
Under Database DevOps in the Harness UI, navigate to DB Schema.
Select Add New DB Schema.

Connect to Data Schema: Connect via Harness Connector or use a custom script to connect to the database schema stored in a remote repository.
Schema Path: The path to the schema file in the repository. This is where the custom script writes the changelog files that Database DevOps should use during pipeline execution.
Image: The Docker image to be used for the custom script. This should be a base image that has the necessary tools and libraries installed to execute your script.
Shell: The shell to be used for executing the script. This can be
bashorsh, both of which are supported by the Docker image.Script: The custom script that runs. This script should include the logic to download and extract the changelog file from the remote repository.
For example:
Select Save.
The DB Schema is created, and you can see the details in the UI.
Select the DB Schema, and then select Add New DB Instance.

Name of DB Instance: The name of the DB Instance. This is the name that is used in the pipeline to refer to this DB Instance.
Tags (optional): Tags to be used for the DB Instance. This can be used to change which instances are shown on the migration state dashboard. If left blank, the tags are automatically generated.
Connector: The JDBC Connector to be used for the DB Instance. This is the connector that connects to the database instance.
Context: The context is used to control which changelogs are deployed to which environments. This is useful when you have multiple environments (for example, dev, test, and prod) and you want to deploy different changelogs to each environment.
Deployment pipeline
Under Database DevOps in the Harness UI, navigate to Pipelines.
Select Create a Pipeline.
Select Add Stage, and then select Custom Stage.
In the Stage section, create Add Step Group as the stage type.
In the Step Group section, select Add Step as the step type. Under DB DevOps, select Apply Schema as the step type.

Select DB Schema: The DB Schema created earlier.
Select DB Instance: The name of the DB Instance, which was created earlier in the DB Schema.
Tags (optional): Tags to be used for the DB Instance. This can be used to identify the DB Instance in the pipeline. If left blank, the tags are automatically generated.
Select Apply Changes, and then select Save.
The pipeline is created, and you can see the details in the UI.
Select Run to run the pipeline.
Final result

You have created a DB Schema and deployed it using a custom script. You can use this pipeline to deploy your DB Schema to the database instance.
Next steps
Go to Automated rollback for database schemas to configure automated rollback for failed deployments.
Go to Configure Author DB Change to use LLM-powered change authoring.
Go to the Troubleshooting Guide to resolve common setup and runtime errors.
Last updated
Was this helpful?