如何从hudson连接mysql?
我正在执行由 selenium 创建并从 hudson 触发的回归测试。在此测试之后,我需要清理数据库,因此 Hudson 中有任何选项可以连接数据库并执行一些脚本吗?或者说做这件事的最好方法是什么?
提前致谢 通过玛尼
I am executing regression test created by selenium and triggered from hudson. After this test i need to clean up DB , so for this any option there in Hudson to connect DB and execute some script? Or what is the best way to do this one?
Thanks in advance
by Mani
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,Hudson/Jenkins 中没有内置插件,但您可以使 Hudson 构建过程执行 shell 脚本/bat 文件,而该文件又可以执行您可以使用脚本执行的任何操作:
Shell 脚本和 Windows 批处理命令
根据您的情况,最好将此步骤添加到整个构建脚本中(例如,作为 ant 中的
任务)。There is no build-in plugin in Hudson/Jenkins that I'm aware of, but you can make the Hudson build process execute a shell script/bat file that in turn can do whatever you can do with a script:
Shell scripts and Windows Batch commands
Depending on your situation it might be preferable to add this step to an overall build script (as an
<exec>
task in ant for example).您可以按照上面的说明进行操作,或者如果您使用 JPA 或 Hibernate 连接到数据库,则可以进行设置,以便每次都重新创建数据库。我在我的案例中就是这样做的。从问题中很难看出你使用哪种方法来连接数据库。
You can do as stated above or if you connect to the databases using JPA or Hibernate you can set up those so the database is recreated each time. That's how I do it on my case. From the question is hard to tell which method you use to connect to the database.
我的测试是通过 TestNG 调用的,在运行之前,我通过 JDBC 清理数据库。
由于您没有说明您正在使用哪个数据库,因此我建议在 Google 上搜索“[DB] JDBC 示例”,将 [DB] 更改为您正在使用的任何 DBMS :)
My tests are being invoked through TestNG and before they run, I clean up the DB via JDBC.
Since you didn't say which DB you are using, I recommending Googling for "[DB] JDBC example", changing [DB] for whatever DBMS you are using :)