diff --git a/cat-maven-plugin/src/main/java/com/dianping/cat/plugin/InstallMojo.java b/cat-maven-plugin/src/main/java/com/dianping/cat/plugin/InstallMojo.java index 67885b6e73..289bd641c1 100644 --- a/cat-maven-plugin/src/main/java/com/dianping/cat/plugin/InstallMojo.java +++ b/cat-maven-plugin/src/main/java/com/dianping/cat/plugin/InstallMojo.java @@ -211,18 +211,32 @@ private boolean setupDatabase() throws MojoFailureException { } private void validate() { - m_jdbcUrl = PropertyProviders.fromConsole().forString("jdbc.url", "Please input jdbc url:", null, - "jdbc:mysql://127.0.0.1:3306", new IValidator() { - @Override - public boolean validate(String url) { - if (url.startsWith("jdbc:mysql://")) { - return true; - } else { - return false; + m_jdbcUrl = System.getenv("mysql_jdbcUrl"); + m_user = System.getenv("mysql_username"); + m_password = System.getenv("mysql_password"); + + if (m_jdbcUrl != null && m_user != null && m_password != null) { + // ignore it + } else { + m_jdbcUrl = PropertyProviders.fromConsole().forString("jdbc.url", "Please input jdbc url:", null, + "jdbc:mysql://127.0.0.1:3306", new IValidator() { + @Override + public boolean validate(String url) { + if (url.startsWith("jdbc:mysql://")) { + return true; + } else { + return false; + } } - } - }); - m_user = PropertyProviders.fromConsole().forString("jdbc.user", "Please input username:", null, null, null); - m_password = PropertyProviders.fromConsole().forString("jdbc.password", "Please input password:", null, "", null); + }); + m_user = PropertyProviders.fromConsole().forString("jdbc.user", "Please input username:", null, null, null); + m_password = PropertyProviders.fromConsole().forString("jdbc.password", "Please input password:", null, "", + null); + + } + + getLog().info("jdbc.url: " + m_jdbcUrl); + getLog().info("jdbc.user: " + m_user); + getLog().info("jdbc.password: " + m_password); } } \ No newline at end of file