Issue
-
After running any CLI command, I get the following stack trace:
javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Connection reset at sun.security.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1533) at sun.security.ssl.AppInputStream.read(AppInputStream.java:95) at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
Environment
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller (version higher or equal to 2.222.1.1)
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Operations Center (version higher or equal to 2.222.1.1)
-
CloudBees CI (CloudBees Core) on traditional platforms - Client controller (version higher or equal to 2.222.1.1)
-
CloudBees CI (CloudBees Core) on traditional platforms - Operations Center (version higher or equal to 2.222.1.1)
-
CloudBees Jenkins Enterprise - Managed controller (version higher or equal to 2.222.1.1)
-
CloudBees Jenkins Enterprise - Operations center (version higher or equal to 2.222.1.1)
-
Jenkins LTS (version higher or equal to 2.222.1)
Resolution
There are some reasons why you face a networking error message when you run the jenkins-cli command. One of them is the Connection reset. In this case, the connection between the jenkins-cli command and the Jenkins server is reset by the jenkins-cli if the task requires too much time to be accomplished by the Jenkins server (like for example moving a too large folder of jobs from one controller to another one).
On this kind of error, the solution is using webSocket for the connection. Using webSocket for the connection we will prevent the timeout of the HTTP request and the jenkins-cli will wait for the Jenkins response.
To run the jenkins-cli command using webSocket you only need to add the argument -webSocket to the command. Please, take a look at the following example:
java -jar jenkins-cli.jar -s $JENKINS_URL -auth $USER:$API_TOKEN -webSocket list-plugins