将liquibase参数传递给gradle liquibase'update'任务 [英] Pass liquibase parameters to gradle liquibase 'update' task

查看:139
本文介绍了将liquibase参数传递给gradle liquibase'update'任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将用户名,密码和url liquibase参数作为命令行参数传递给gradle的liquibase更新任务.

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

我已按照 liquibase-gradle-plugin 配置插件. 我真正想要实现的是在运行时传递这些数据库参数,而不是在liquibase.properties文件中对其进行硬编码.

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.

我可以通过将这三个值导出为环境变量并在build.gradle中对其进行访问来做到这一点.但是我想使用命令行参数来实现这一点.

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.

我尝试了

gradle更新--url = jdbc:postgresql://localhost:5432/liquibase_cmd_test-用户名= ###-密码= ### -PrunList = main

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

但它给出错误为

未知的命令行选项'--url'.

Unknown command-line option '--url'.

推荐答案

我认为gradle之下是Java,因此您应该可以执行以下操作. -D参数设置系统属性.

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

这篇关于将liquibase参数传递给gradle liquibase'update'任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆