New Webinar: The New GitHub Action That Replaces 50 Others
Blog Post

Liquibase Environment Variables Explained

See Liquibase in Action

Accelerate database changes, reduce failures, and enforce governance across your pipelines.

Watch a Demo

Table of contents

Content updated September 2025

Key Takeaways

  • Liquibase environment variables simplify deployments by eliminating the need for multiple liquibase.properties files.
  • They improve security by keeping passwords, URLs, and credentials out of source control.
  • They reduce human errors by centralizing configuration on the server side.
  • Integration with CI/CD tools like Jenkins makes setup and management straightforward.
  • Teams gain more control, consistency, and confidence when deploying database changes.

Teams can now set where, when, and how Liquibase deploys database changes at the environment level. You no longer need to manage separate liquibase.properties files for different environments!

3 Reasons to Use Liquibase Environment Variables

Make it easier for teams to give the right permissions to the right team members. With environment variables in place, it’s easier for developers to focus on building their code instead of worrying about their connection strings and property information.

For example, without environment variables, when a developer needs to change a flag during runtime, it can get tedious (and error-prone):

liquibase \
  --changeLogFile=myChangeLog.sql \
  --contexts=test,stage \
  --labels=Jira223 \
  --url=jdbc:mysql://hostname:3306/TEST \
  --username=user1 \
  --password=myStrongPassword \
  --defaultSchemaName=mySchema \
  --referenceUrl=jdbc:mysql://hostname:3306/DEV \
  --referenceUsername=refUsername \
  --referencePassword=refPassword \
  --logLevel=FINE \
  --classpath=/path/to/jdbc/mysql-connector-java-8.0.18.jar \
  update

Much easier!

Now, with environment variables set up prior to running commands, developers only need to do this:

liquibase update

Ensure no emails, passwords, URLs, and other sensitive information gets pulled into source control. Since the liquibase.properties file contains properties such as the URL path to the database along with a username and password, placing this file in source control is not a good idea. By setting up Liquibase environment variables, all of this information can be stored in a secure environment before running commands on the server where the automation job is running.

Another advantage to separating the configuration with your repository is that when a password or other keys/values are changed, no changes need to occur in the code. The environment variables can just be updated to take effect.

With Liquibase environment variables, you can prevent more mistakes from happening. When you configure Liquibase and manage the configuration on the server side, developers never have to see or deal with it. It significantly decreases the chances that changes are deployed to the wrong place, saving a lot of time and confusion.

What the users & developers see

In the following Jenkins build configuration, we are setting the Liquibase environment variables as a first step, by sourcing the exp_lb_env_vars.sh script in the build server’s home directory.

For example:

. ~/exp_lb_env_vars.sh & >/dev/null

Notice that the user doesn’t have any idea what the properties are. The properties are fully managed by whoever has the access to maintain the exp_lb_env_vars.sh file on the server side.

Setting up Liquibase environment variablesTypically, a DevOps team member (or someone with a special authority with access to the database) can create a shell script similar to the one below. We’ll call it exp_lb_env_vars.sh. This script contains several “export” commands to set the Liquibase environment variables.

#!/bin/bashexport LIQUIBASE_COMMAND_USERNAME="username"export LIQUIBASE_COMMAND_PASSWORD="password"export LIQUIBASE_COMMAND_URL="jdbc connection url"export LIQUIBASE_PRO_LICENSE_KEY="pro key"export LIQUIBASE_CLASSPATH="/path/to/jdbc/driver"export LIQUIBASE_HUB_API_KEY="hub api key"export LIQUIBASE_HUB_MODE="all"PATH=/root/liquibase:$PATH

Setting Liquibase environment variables in Jenkins

Go to Manage Jenkins → Configure system

Under Global properties click the Add button to add the Liquibase environment variable in the Name box, and the value under the Value box.

See our documentation for more information..

Frequently Asked Questions

Q1: What are Liquibase environment variables?
They are configuration values (like URLs, usernames, passwords) set at the system or server level so they don’t need to be included in liquibase.properties files.

Q2: Why should I use environment variables instead of properties files?
They prevent sensitive credentials from being committed to source control and make it easier to update settings without touching code.

Q3: How do environment variables reduce mistakes?
By centralizing configuration, developers don’t have to manage connection details directly, reducing the risk of deploying changes to the wrong environment.

Q4: Can environment variables be used in CI/CD pipelines?
Yes. They integrate seamlessly with Jenkins and other automation servers for secure, consistent deployments.

Tsvi Zandany
Tsvi Zandany
Share on:

See Liquibase in Action

Accelerate database changes, reduce failures, and enforce governance across your pipelines.

Watch a Demo