Luka Špoljarić
Luka Špoljarić

Reputation: 999

Liquibase.properties read env variables

I'm using liquibase via command line, i am wondering how to setup liquibase.properties file to read environment variables?

something like:

***liquibase.properties***

    driver=org.postgresql.Driver
    classpath=lib/postgresql-42.2.5.jar 

    url=${DATASOURCE_URL}
    username=${DATASOURCE_USERNAME} 
    password=${DATASOURCE_PASSWORD}

    changeLogFile=changelogs/master.yaml

Upvotes: 6

Views: 15254

Answers (2)

Christian Kämper
Christian Kämper

Reputation: 29

For the time being there is no way to use environment variables in the liquibase.properties file. This have to be implemented in the source code since Java by default won't recognize them. See https://stackoverflow.com/a/2263944/5418766 for details.

I had a similar problem trying to read the database credentials from a Bitwarden vault. I've ended up using the variables in the batch file (I'm using Windows) calling Liquibase and that worked for me.

Upvotes: 2

bilak
bilak

Reputation: 4954

here you have info about liquibase properties. However if you want to use your own properties you can put in property file parameter.property1 and then use ${property1} in your changelog as placeholder.

Upvotes: 0

Related Questions