Retrieve any configuration property in a Custom Policy check
Last updated: September 2, 2025
The liquibase_utilities.get_config_value
python helper function allows you to retrieve any configuration property which includes environment variables, system properties, flow files, flow variables, and checks run
command line arguments. Conceptually, it works like property substitution within a Custom Policy check.
Syntax: liquibase_utilities.get_config_value("
CONFIGURATION_PROPERTY_VALUE
")
Retrieve any configuration property in a Custom Policy check
Have an existing checks settings file
Ensure the property you want to pull into your Custom policy check is set in one of the following ways:
Global flow file argument
Global CLI parameter
JAVA_OPTS Environment Variable system property
Liquibase environment variable
Procedure
Create a new file in your Liquibase working directory or a subdirectory like /scripts.
This file will contain the Python script that is your custom policy check. In this example, we title our new file custom_check_no_tables.py
.
Open the new custom_check_no_tables.py file and add the following custom policy check to it:
Retrieve any configuration property in a Custom Policy check
#
import Liquibase modules containing useful functions
import liquibase_utilities as lb
import sys
# define reusable variables
obj = lb.get_database_object() # database object to examine
liquibase_status = lb.get_status() # Status object of the check
# write check logic
# this condition checks
if the current object is a table
# and whether it starts with the prefix 'tbl_'
if lb.is_table(obj) and not obj.getName().lower().startswith("tbl_"):
# indicate that the custom check has been triggered
liquibase_status.fired = True
# set the message
for Liquibase to
return when check is triggered
liquibase_status.message = "Tables must start with the prefix tbl_. Add this prefix."
# halt execution of the script
sys.exit(1)
#
default
return code
False
Liquibase will run the check against every object in the database, so this script doesn't need a Python looping mechanism to iterate through database objects.
Navigate to your Custom policy check Python script and add the configuration value desired.
This configuration value could be an environment variable, a system property, flow file, flow variable, or a checks run argument.
Helper function syntax: config_value=liquibase_utilities.get_config_value("
your-config-value
")
Examples of helper functions |
|
|
|
In this example, we will add the following piece of code to the Custom policy check which pulls in two configuration values called loglevel and mychangelog .
You can replace myloglevel
and mychangelog
with any property configured in the liquibase.properties file, flow file, global CLI parameters, JVM system properties, or as an environment variable.
#pull the database url, loglevel, and changelogfile into this policy check message.
myloglevel = liquibase_utilities.get_config_value("loglevel")
mychangelog = liquibase_utilities.get_config_value("changelogfile")
logger.info("LOG LEVEL = " + myloglevel)
logger.info("CHANGELOG FILE = " + mychangelog)
Once the helper function is added, your script will look similar to this:
#import Liquibase modules containing useful functions
import liquibase_utilities as lb
import sys
# define reusable variables
obj = lb.get_database_object() # database object to examine
liquibase_status = lb.get_status() # Status object of the check
#pull the database loglevel and changelogfile into this policy check message.
myloglevel = liquibase_utilities.get_config_value("loglevel")
mychangelog = liquibase_utilities.get_config_value("changelogfile")
logger.info("LOG LEVEL = " + myloglevel)
logger.info("CHANGELOG FILE = " + mychangelog)
# write check logic
# this condition checks
if the current object is a table
# and whether it starts with the prefix 'tbl_'
if lb.is_table(obj) and not obj.getName().lower().startswith("tbl_"):
# indicate that the custom check has been triggered
liquibase_status.fired = True
# set the message
for Liquibase to
return when check is triggered
liquibase_status.message = "Tables must start with the prefix tbl_. Add this prefix."
# halt execution of the script
sys.exit(1)
#
default
return code
False