詹金斯添加新节点

时间:2020-02-13 02:09:21

标签: jenkins ssh

我正在尝试设置Jenkins进行生产部署。目的是允许Jenkins在生产服务器上执行git clone,构建和部署等。

Jenkins在Configuration Management Server(CentOs 7)上运行,而Production Server是另一台服务器(Centos 7)。

我首先在Jenkins中使用以下配置创建了一个新节点:

enter image description here

然后我将Production Server IP地址添加到Jenkins已知主机,如下所示

-bash-4.2$ cat /var/lib/jenkins/.ssh/known_hosts
192.168.1.xx ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYblabla=

我确认可以在Jenkins帐户下的Configuration Management服务器上将ssh转到Production Server。

但是在詹金斯上,节点状态始终是这样的:

This agent is offline because Jenkins failed to launch the agent process on it.

节点日志如下:

SSHLauncher{host='192.168.1.xx', port=22, credentialsId='service account at w', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.NonVerifyingKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
[02/12/20 20:57:51] [SSH] Opening SSH connection to 192.168.1.xx:22.
[02/12/20 20:57:51] [SSH] WARNING: SSH Host Keys are not being verified. Man-in-the-middle attacks may be possible against this connection.
ERROR: Server rejected the 1 private key(s) for service_account (credentialId:service_account at webi/method:publickey)
[02/12/20 20:57:51] [SSH] Authentication failed.
Authentication failed.
[02/12/20 20:57:51] Launch failed - cleaning up connection
[02/12/20 20:57:51] [SSH] Connection closed.

有人可以解决以下问题吗?

  1. 我还需要在Production Server上安装Jenkins吗?
  2. 如何配置Jenkins在其上运行管道 新节点?

1 个答案:

答案 0 :(得分:0)

好吧,我终于想通了:

无需在Production Server上安装Jenkins;

SSH连接失败的原因是Jenkins设置的凭据错误。本质上,Jenkins将执行SSH连接,因此应使用用户名/密码。所以我要做的是创建一个新的凭据,Jenkins会将JAR文件复制到/ var / jenkins目录。

您还需要更改/ var / jenkins目录的所有权!