Jenkins CLI连接被拒绝 [英] Jenkins CLI connection refused

查看:727
本文介绍了Jenkins CLI连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行时

java -jar jenkins-cli.jar -s https://jenkins_url help

由于某种原因,我的连接被拒绝. Jenkins版本是1580.3,用户具有Jenkins服务器的权限,cli jar是最新的,并且ssh公钥已正确配置.知道是什么原因造成的吗?这是堆栈跟踪是否有帮助:

I'm getting connection refused for some reason. Jenkins version is 1580.3, user has the permissions on Jenkins server, cli jar is up-to-date and ssh public key is configured properly. Any idea what might be causing this? Here's the stack trace if it will help:

Exception in thread "main" java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at hudson.cli.CLI.connectViaCliPort(CLI.java:203)
at hudson.cli.CLI.<init>(CLI.java:126)
at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)
at hudson.cli.CLI._main(CLI.java:466)
at hudson.cli.CLI.main(CLI.java:382)
Suppressed: java.io.EOFException: unexpected stream termination
at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:331)
at hudson.remoting.Channel.<init>(Channel.java:421)
at hudson.remoting.Channel.<init>(Channel.java:400)
at hudson.remoting.Channel.<init>(Channel.java:396)
at hudson.remoting.Channel.<init>(Channel.java:385)
at hudson.remoting.Channel.<init>(Channel.java:377)
at hudson.remoting.Channel.<init>(Channel.java:353)
at hudson.cli.CLI.connectViaHttp(CLI.java:157)
at hudson.cli.CLI.<init>(CLI.java:130)
... 3 more

推荐答案

如果连接被拒绝,则可能禁用了CLI,但是很可能存在防火墙或网络问题.

If the connection is refused, perhaps the CLI is disabled, but more likely there's a firewall or network issue.

对Jenkins的每个成功的HTTP请求都将CLI端口作为HTTP标头进行响应,因此您可以快速检查它是否已启用:

Each successful HTTP request to Jenkins responds with the CLI port as an HTTP header, so you can quickly check whether it's enabled:

curl -sI http://jenkins/ | grep CLI

或者,如记录在Wiki ,您可以检查是否已启用TCP端口.在 http://jenkins/configureSecurity/

Alternatively, as documented on the wiki, you can check whether the TCP port is enabled. Look for "TCP port for JNLP slave agents" at http://jenkins/configureSecurity/

但是,由于您的堆栈跟踪表明CLI客户端正在尝试建立与特定端口的连接,因此它建议启用CLI,并且Jenkins在其HTTP响应中公布该端口号.

However, since your stacktrace indicates that the CLI client is trying to establish a connection to a particular port, it suggests that the CLI is enabled, and Jenkins is advertising that port number in its HTTP responses.

因此,您可以尝试手动连接到该端口,以检查其是否打开:

So you could try to connect to that port manually, to check whether it's open:

telnet jenkins <cli-port>

如果在此还看到拒绝连接",则说明您的Jenkins和CLI客户端设置似乎可以,但是存在网络问题.在这种情况下,请检查Jenkins服务器上的防火墙是否允许该CLI端口上的传入连接.

If you also see "Connection refused" here, then you know that your Jenkins and CLI client setup seem to be ok, but you have a network issue. In which case, check that the firewall on the Jenkins server allows incoming connections on that CLI port.

要简化防火墙配置,可以在上述配置安全性"页面中从随机端口切换到固定端口.

To make firewall configuration easier, you can switch from a random port to a fixed port in the "configure security" page mentioned above.

这篇关于Jenkins CLI连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆