Pass liquibase parameters to gradle liquibase 'update' task

我与影子孤独终老i 提交于 2020-06-27 10:33:50

问题


I want to pass username, password and url liquibase parameters as a command line parameters to gradle's liquibase update task.

I have followed liquibase-gradle-plugin to configure the plugin. What I actually want to achieve is, pass these database parameters at runtime instead of hardcoding them in liquibase.properties file.

I can do this by exporting these three values as environment variables and access them in build.gradle. But I want to achieve this using commandline parameters.

I tried

gradle update --url=jdbc:postgresql://localhost:5432/liquibase_cmd_test --username=### --password=### -PrunList=main

but it gives error as

Unknown command-line option '--url'.


回答1:


I think that underneath gradle is Java, so you should be able to do something like this. The -D argument sets a system property.

gradle -Dliquibase.url=<your url> -Dliquibase.username=<username> -Dliquibase.password=<password> update -PrunList=main


来源:https://stackoverflow.com/questions/50347311/pass-liquibase-parameters-to-gradle-liquibase-update-task

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!