我正在使用docker-slaves插件在jenkins中创建mysql容器。完整设置在localhost上运行。我无法从node.js脚本连接到mysql容器。
error connecting: Error: connect ECONNREFUSED 127.0.0.1:3306
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
连接脚本如下:
const connection = mysql.createConnection({
host: mysqlHost,
user: mysqlUser,
password: mySqlPassword,
database: mysqlDb
});
connection.connect((err) => {
if (err) {
console.error('error connecting: ' + err.stack);
//return;
}
//console.log('connected as id ' + connection.threadId);
});
使用docker-slaves插件进行Jenkins作业配置: