在 Jenkins 服务器上使用 MySQL DB 时无法运行 spring boot mvn 测试用例

问题描述 投票:0回答:0

我是 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)

非常感谢任何帮助:

java mysql spring-boot jenkins jenkins-pipeline
© www.soinside.com 2019 - 2024. All rights reserved.