Erran Morad
Erran Morad

Reputation: 4743

Cannot run jenkins cli

Using this tutorial, I am trying to run Jenkins cli in a windows 10 laptop as shown below. 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. Tomcat runs on port 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)

Upvotes: 5

Views: 6040

Answers (3)

Behzad Soltaniyan
Behzad Soltaniyan

Reputation: 141

You can use this command for open the jankins


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


but you need to login automatically you can read about SSO on Jenkins

or you are trigger job on Jenkins you can read to use API

Upvotes: 0

Bluescreenterror
Bluescreenterror

Reputation: 106

Is running the cli over ssh an Option for you ? If yes try the following:

  1. Install putty on client machine
  2. Generate open ssh key with puttygen, save private key
  3. Copy the key to the user which should rum the cli (Userpage=> configure => SSH Public Keys
  4. Activate ssh under global security with Static Port
  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"

Upvotes: 0

Graziano Panzera
Graziano Panzera

Reputation: 96

You should check the exact url and address of the Jenkins instance inside your tomcat.

If you can access the web UI at, for example, http://localhost:8080/jenkins you should run your client as:

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

Upvotes: 3

Related Questions