简体   繁体   English

无法运行 jenkins cli

[英]Cannot run jenkins cli

Using this tutorial , I am trying to run Jenkins cli in a windows 10 laptop as shown below.使用本教程,我正在尝试在 windows 10 笔记本电脑中运行 Jenkins cli,如下所示。 But, I am getting an exception.但是,我遇到了一个例外。 How do I find out why the exception occurs and how to fix it?如何找出异常发生的原因以及如何解决?

Note that I first ran my jenkins.war on port 9090. Then, I moved it into tomcat webapps.请注意,我首先在端口 9090 上运行了 jenkins.war。然后,我将其移至 tomcat webapps。 Tomcat runs on port 8080. Tomcat 在端口 8080 上运行。

C:\mystuff\jenkins-cli>java -jar jenkins-cli.jar -s http://localhost:9090/
java.net.ConnectException: Connection refused: connect
        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at java.net.Socket.connect(Socket.java:538)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
        at sun.net.www.http.HttpClient.New(HttpClient.java:339)
        at sun.net.www.http.HttpClient.New(HttpClient.java:357)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1202)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:966)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1316)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1291)
        at hudson.cli.FullDuplexHttpStream.<init>(FullDuplexHttpStream.java:71)
        at hudson.cli.CLI.plainHttpConnection(CLI.java:279)
        at hudson.cli.CLI._main(CLI.java:271)
        at hudson.cli.CLI.main(CLI.java:83)

You should check the exact url and address of the Jenkins instance inside your tomcat.您应该检查 tomcat 中 Jenkins 实例的确切 url 和地址。

If you can access the web UI at, for example, http://localhost:8080/jenkins you should run your client as:如果您可以访问 web UI,例如http://localhost:8080/jenkins ,您应该将客户端运行为:

java -jar jenkins-cli.jar -s http://localhost:8080/jenkins/

You can use this command for open the jankins您可以使用此命令打开 jankins


java -jar jenkins-cli.jar -s http://localhost:8080/jenkins/ java -jar jenkins-cli.jar -s http://localhost:8080/jenkins/


but you need to login automatically you can read about SSO on Jenkins但是您需要自动登录,您可以在 Jenkins 上阅读有关SSO的信息

or you are trigger job on Jenkins you can read to use API或者您是 Jenkins 上的触发作业,您可以阅读以使用API

Is running the cli over ssh an Option for you?在 ssh 上运行 cli 是否适合您? If yes try the following:如果是,请尝试以下操作:

  1. Install putty on client machine在客户端机器上安装腻子
  2. Generate open ssh key with puttygen, save private key用puttygen生成打开的ssh密钥,保存私钥
  3. Copy the key to the user which should rum the cli (Userpage=> configure => SSH Public Keys将密钥复制给应该朗读 cli 的用户(用户页面 => 配置 => SSH 公钥
  4. Activate ssh under global security with Static Port使用 Static 端口在全局安全下激活 ssh
  5. Check if you can connect to your Server via ssh (you can use plink for that, comes with putty) plink.exe -P Port_from_point_4 -no-antispoof -batch -i "Path_to_private_key_point_2" user@Jenkins-IP help"检查您是否可以通过 ssh 连接到您的服务器(您可以为此使用 plink,随附腻子) plink.exe -P Port_from_point_4 -no-antispoof -batch -i "Path_to_private_key_point_2" user@Jenkins-IP help"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM