How can I populate Liquibase parameter values from an external properties file?


Solution 1

Do that at compile time: sounds like job for maven filters and/or profiles

NOTE: be carefull with liquibase and any "marker" replacements... liquibase stores CRC of applied changessets


<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">




<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog logicalFilePath="liquibase.xml" xmlns="" xmlns:xsi=""

    <changeSet author="me" id="changeSetId1">

        <createTable tableName="${}">
            <column name="id" type="int" />
            <column name="${}" type="varchar(${column1.length})" />
            <column name="${}" type="int" />


EDIT: A typical invocation (using filtered resources) would look like this: mvn resources:resources liquibase:update or more preferably use profiles... mvn resources:resources liquibase:update -P<profile_name>

EDIT2: There is one big advantage of this way of defining columns. You could use this property's (e.g.: column1.length) value (e.g.: 10) for validation of every layer: Hibernate, DAO, WEB, faces, JavaScript. Just use this property at each place where you need to validate against it. Even in i18n/ if needed (e.g.: input1.validation=No more than ${column1.length} letters.).

The only complication is that if you need to change this value you need to provide proper liquibase update/rollback script. Sometimes it is possible to change value and set new liquibase checksum (safe operation like increase varchar length), but other times you need to create a safe update changescript using new property/value.

Solution 2

Take a look at here. You can either use a command line arguments (-D[arg name]=[arg value]) or environment variables. If you don't use any build manager tool such as Maven or Ant you will need to write a script for reading parameters from file and passing them to the command. Example


Related videos on Youtube

Author by


Updated on October 02, 2022


  • amoe
    amoe over 1 year

    Is there any way that I can populate parameters in a Liquibase changelog file based on the contents of an external property file?

    As in, I would like to be able to say:

    <createTable tableName="${}">
         <column name="id" type="int"/>
         <column name="${}" type="varchar(${column1.length})"/>
         <column name="${}" type="int"/>

    And keep the value of and the other parameters in an external file, and reference this file either from within the changelog, or from the Liquibase command line, or as an option of the Maven plugin that runs liquibase.

    I can't seem to find any way to do this, is it possible?

  • amoe
    amoe over 10 years
    Can Maven dynamically build the command line from a properties file, defining all -Dname=value pairs automatically for liquibase?
  • Diana Amza
    Diana Amza over 9 years
    Hi Wooff! I'm trying to use the same structure but I'm getting an error when I run liquibase:update - '' in properties file is not being used by this task.