Closed agustin-tecso closed 2 years ago
The simplest way to do this is with Gradle properties. The first part is to put properties in your build.gradle's liquibase
configuration like this:
liquibase {
activities {
main {
changeLogFile "${dbDir}/changelog.groovy"
url project.ext.jdbcUrl
username project.ext.jdbcUsername
password project.ext.jdbcPassword
logLevel 'info'
}
}
}
There are several ways to specify the values for those variables at runtime, including -P jdbcPassword=mypass
. Gradle even has a way to set properties from environment variables, using specially named variables like ORG_GRADLE_PROJECT_jdbcPassword=mypass
.
I can't resist a bit of shameless self promotion - the different ways of setting properties, and the order of precedence, is explained my Gradle Properties Plugin. You probably don't actually need the plugin itself, since all but 2 of the methods described in the documentation is built into Gradle itself, but it can come in handy in setups like this.
When I run Liquibase I use the plugin. The username for all environments is the same, so I put it in the gradle.properties file. The database URLs are different for each environment, so I put those in the gradle-
Hi! I want to run update command from the console for update production database. I need to pass password with enviroment variable for security concerns. Gradle don't recognize any parameters of liquidbase, I have tried:
gradle -Dliquibase.changeLogFile=liquibase/config/changelog-master.xml update gradle --changeLogFile=liquibase/config/changelog-master.xml update gradle --changelog-file=liquibase/config/changelog-master.xml update
¿Is there any way to pass parameters from gradle to liquibase plugin? Put a production password in a file is not an option.
Thanks in advance!