jenkins连接mysql_mysql – 如何将JDBC驱动程序添加到Jenkins管道?

MySQL DataBase Plugin文档中可以看到包含MySQL的jdbc驱动程序:

Note that MySQL JDBC driver is under GPLv2 with FOSS exception. This

plugin by itself qualifies under the FOSS exception, but if you are

redistributing this plugin, please do check the license terms.

Drizzle(+MySQL) Database Plugin is available as an alternative to this

plugin, and that one is under the BSD license.

更具体地说,此插件的实际最新版本(1.1)包含连接器版本5.1.38:

Version 1.1 (May 21, 2016) mysql-connector version 5.1.38

因此,为了使驱动程序可用,您必须强制驱动程序进行注册.

为此,请在代码中实例化连接之前使用Class.forName(“com.mysql.jdbc.Driver”):

import groovy.sql.Sql

node{

Class.forName("com.mysql.jdbc.Driver")

def sql = Sql.newInstance("jdbc:mysql://mysql:3306/test_db", "user","passwd", "com.mysql.jdbc.Driver")

def rows = sql.execute "select count(*) from test_table;"

echo rows.dump()

}

更新:

为了在Jenkins管道groovy脚本中提供JDBC连接器类,您需要将DataBase plugin更新为上一个当前版本:

Version 1.5 (May 30, 2016) Pipeline Support

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值