我是 Jenkins 服务器的新手,目前正在测试它。但是,我遇到以下情况的错误:
我有一个带有 MySQL 数据库的 Spring Boot 应用程序,我正试图在 Jenkins 服务器上运行一个测试用例。不幸的是,Jenkins 服务器无法连接到 MySQL 数据库。
为了解决问题,我添加了以下步骤以进行测试:
stage('Run the test cases'){
steps{
withCredentials([usernamePassword(credentialsId: '4a632d56-baf5-4455-90fe-21e6823f58f1', passwordVariable: 'password', usernameVariable: 'user')]) {
sh "mysql connection"
sh "mysql -h 192.168.112.2 -umaninder -pmaninder"
sh "connection testing done"
sh "mvn test"
}
}
}
我已经提到了安装我的 MySQL 服务器的机器的 IP 地址,如果我在 Jenkins 机器终端上使用相同的命令,我可以连接 MySQL DB,但不知何故这里失败了。
错误: ERROR 2002 (HY000): 无法通过套接字 '/run/mysqld/mysqld.sock' 连接到本地 MySQL 服务器 (2)
非常感谢任何帮助: