• Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Blocker Blocker
    • cli
    • None

      We are trying to connect Jenkins CLI remote trigger. After 2.440.1 till the latest Version we are getting this handshake error. Please check this

      java -jar jenkins-cli.jar -s https://*****/version_release_testing/ -auth ****:**** version io.jenkins.cli.shaded.jakarta.websocket.DeploymentException: Handshake error.         at io.jenkins.cli.shaded.org.glassfish.tyrus.client.ClientManager$3$1.run(ClientManager.java:658)         at io.jenkins.cli.shaded.org.glassfish.tyrus.client.ClientManager$3.run(ClientManager.java:696)         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)         at io.jenkins.cli.shaded.org.glassfish.tyrus.client.ClientManager$SameThreadExecutorService.execute(ClientManager.java:849)         at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)         at io.jenkins.cli.shaded.org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:493)         at io.jenkins.cli.shaded.org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:337)         at hudson.cli.CLI.webSocketConnection(CLI.java:364)         at hudson.cli.CLI._main(CLI.java:324)         at hudson.cli.CLI.main(CLI.java:103) Caused by: io.jenkins.cli.shaded.org.glassfish.tyrus.core.HandshakeException: Response code was not 101: 403.         at io.jenkins.cli.shaded.org.glassfish.tyrus.client.TyrusClientEngine.processResponse(TyrusClientEngine.java:301)         at io.jenkins.cli.shaded.org.glassfish.tyrus.container.jdk.client.ClientFilter.processRead(ClientFilter.java:167)         at io.jenkins.cli.shaded.org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:111)         at io.jenkins.cli.shaded.org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:113)         at io.jenkins.cli.shaded.org.glassfish.tyrus.container.jdk.client.SslFilter.handleRead(SslFilter.java:402)         at io.jenkins.cli.shaded.org.glassfish.tyrus.container.jdk.client.SslFilter.processRead(SslFilter.java:365)         at io.jenkins.cli.shaded.org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:111)         at io.jenkins.cli.shaded.org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:113)         at io.jenkins.cli.shaded.org.glassfish.tyrus.container.jdk.client.TransportFilter$4.completed(TransportFilter.java:295)         at io.jenkins.cli.shaded.org.glassfish.tyrus.container.jdk.client.TransportFilter$4.completed(TransportFilter.java:279)         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)         at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:221)         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)         at java.base/java.lang.Thread.run(Thread.java:840)

          [JENKINS-73329] Jenkins CLI remote trigger is not working

          Mark Waite added a comment - - edited

          Thanks for using Jenkins. I can duplicate the behavior that you're reporting with the following command that uses an incorrect server URL:

          java -jar jenkins-cli.jar -s http://mark-pc2.markwaite.net:8080/Hosting-Providers -auth  mwaite:my-token-value
          

          I can resolve the problem by using the correct server URL:

          java -jar jenkins-cli.jar -s http://mark-pc2.markwaite.net:8080/ -auth  mwaite:my-token-value
          

          Closing as "not a defect"

          The help for the arguments to jenkins-cli.jar is:

          $ java -jar jenkins-cli.jar -help
          Neither -s nor the JENKINS_URL env var is specified.
          Jenkins CLI
          Usage: java -jar jenkins-cli.jar [-s URL] command [opts...] args...
          Options:
           -s URL              : the server URL (defaults to the JENKINS_URL env var)
           -webSocket          : connect using WebSocket (the default; works well with most reverse proxies; requires Jetty)
           -http               : use a pair of HTTP(S) connections rather than WebSocket
           -ssh                : use SSH protocol rather than WebSocket (requires -user; SSH port must be open on server)
           -i KEY              : SSH private key file used for authentication (for use with -ssh)
           -noCertificateCheck : bypass HTTPS certificate check entirely. Use with caution
           -noKeyAuth          : do not try to load the SSH authentication private key. Conflicts with -i
           -user               : specify user (for use with -ssh; must have registered a public key)
           -strictHostKey      : request strict host key checking (for use with -ssh)
           -logger FINE        : enable detailed logging from the client
           -auth [ USER:SECRET | @FILE ] : specify username and either password or API token (or load from them both from a file);
                                           for use with -http.
                                           Passing credentials by file is recommended.
                                           See https://www.jenkins.io/redirect/cli-http-connection-mode for more info and options.
           -bearer [ TOKEN | @FILE ]     : specify authentication using a bearer token (or load the token from file);
                                           for use with -http. Mutually exclusive with -auth.
                                           Passing credentials by file is recommended.
          
          The available commands depend on the server. Run the 'help' command to see the list.
          

          The Pipeline documentation describes JENKINS_URL as:

          Full URL of Jenkins, such as https://example.com:port/jenkins/ (NOTE: only available if Jenkins URL set in "System Configuration")

          The environment variables page that is available from freestyle jobs shows the value of JENKINS_URL for that job. On my controller, it shows http://mark-pc2.markwaite.net:8080.

          Mark Waite added a comment - - edited Thanks for using Jenkins. I can duplicate the behavior that you're reporting with the following command that uses an incorrect server URL: java -jar jenkins-cli.jar -s http: //mark-pc2.markwaite.net:8080/Hosting-Providers -auth mwaite:my-token-value I can resolve the problem by using the correct server URL: java -jar jenkins-cli.jar -s http: //mark-pc2.markwaite.net:8080/ -auth mwaite:my-token-value Closing as "not a defect" The help for the arguments to jenkins-cli.jar is: $ java -jar jenkins-cli.jar -help Neither -s nor the JENKINS_URL env var is specified. Jenkins CLI Usage: java -jar jenkins-cli.jar [-s URL] command [opts...] args... Options: -s URL : the server URL (defaults to the JENKINS_URL env var ) -webSocket : connect using WebSocket (the default ; works well with most reverse proxies; requires Jetty) -http : use a pair of HTTP(S) connections rather than WebSocket -ssh : use SSH protocol rather than WebSocket (requires -user; SSH port must be open on server) -i KEY : SSH private key file used for authentication ( for use with -ssh) -noCertificateCheck : bypass HTTPS certificate check entirely. Use with caution -noKeyAuth : do not try to load the SSH authentication private key. Conflicts with -i -user : specify user ( for use with -ssh; must have registered a public key) -strictHostKey : request strict host key checking ( for use with -ssh) -logger FINE : enable detailed logging from the client -auth [ USER:SECRET | @FILE ] : specify username and either password or API token (or load from them both from a file); for use with -http. Passing credentials by file is recommended. See https: //www.jenkins.io/redirect/cli-http-connection-mode for more info and options. -bearer [ TOKEN | @FILE ] : specify authentication using a bearer token (or load the token from file); for use with -http. Mutually exclusive with -auth. Passing credentials by file is recommended. The available commands depend on the server. Run the 'help' command to see the list. The Pipeline documentation describes JENKINS_URL as: Full URL of Jenkins, such as https://example.com:port/jenkins/ (NOTE: only available if Jenkins URL set in "System Configuration") The environment variables page that is available from freestyle jobs shows the value of JENKINS_URL for that job. On my controller, it shows http://mark-pc2.markwaite.net:8080 .

          Pradeep added a comment -

          Hello Team,

          We are providing the correct URL as mentioned in the replicated scenario response. Due to our security concerns, I have masked the URL with * . 

          The real issue is whenever we are trying to remote trigger the Jenkins CLI, we are getting this handshake error. It actually works with the Jenkins LTS version before 2.440.1.

          I have attached the log in the previous response. Hoping for a solution on this.

          Pradeep added a comment - Hello Team, We are providing the correct URL as mentioned in the replicated scenario response. Due to our security concerns, I have masked the URL with * .  The real issue is whenever we are trying to remote trigger the Jenkins CLI, we are getting this handshake error. It actually works with the Jenkins LTS version before 2.440.1. I have attached the log in the previous response. Hoping for a solution on this.

          Mark Waite added a comment -

          We are providing the correct URL as mentioned in the replicated scenario response. Due to our security concerns, I have masked the URL with * .

          You are not providing the correct URL to the -s argument in the sample that you provided. The -s parameter takes the root URL of the Jenkins controller but in your example you are providing a URL that includes "/version_release_testing/" as part of the -s argument That is not the correct syntax for the -s argument. It should only be the root URL of the Jenkins controller.

          If you are using a reverse proxy and have configured "/version_release_testing/" as part of that reverse proxy, then you probably need to check the configuration of the Jenkins controller to assure that it is correctly declaring the root URL of the controller. That is configured in "Manage Jenkins" >> "System".

          Mark Waite added a comment - We are providing the correct URL as mentioned in the replicated scenario response. Due to our security concerns, I have masked the URL with * . You are not providing the correct URL to the -s argument in the sample that you provided. The -s parameter takes the root URL of the Jenkins controller but in your example you are providing a URL that includes "/version_release_testing/" as part of the -s argument That is not the correct syntax for the -s argument. It should only be the root URL of the Jenkins controller. If you are using a reverse proxy and have configured "/version_release_testing/" as part of that reverse proxy, then you probably need to check the configuration of the Jenkins controller to assure that it is correctly declaring the root URL of the controller. That is configured in "Manage Jenkins" >> "System".

          Pradeep added a comment -

          Hello Mark,

          I don't think you get this properly, the issue is not with the syntax we provide. The issue with the Jenkins CLI whenever we try to use jenkins cli for eg version with this command (java -jar jenkins-cli.jar -s https://rb-desrip.de.pure.com/OSE/ help) it throws the handshake error where as previous jenkins versions before 2.440.1 jenkins-cli.jar file are working

          Pradeep added a comment - Hello Mark, I don't think you get this properly, the issue is not with the syntax we provide. The issue with the Jenkins CLI whenever we try to use jenkins cli for eg version with this command (java -jar jenkins-cli.jar -s https://rb-desrip.de.pure.com/OSE/ help) it throws the handshake error where as previous jenkins versions before 2.440.1 jenkins-cli.jar file are working . 

          Mark Waite added a comment -

          pradeep_m I can't duplicate the issue as you have described it. I can duplicate the issue when I use the wrong URL for the Jenkins controller.

          Since you state that you are using the correct URL for the Jenkins controller and your URL includes HTTPS and a path ("OSE"), then I assume that you are using a reverse proxy and have configured the reverse proxy to provide HTTPS. Jenkins works very well for me in that configuration. I have a Jenkins controller with an nginx reverse proxy and HTTPS and am able to run java -jar jenkins-cli.jar -s https://home.markwaite.net/jenkins help without any issue.

          If you are using a reverse proxy, then it is worth confirming that the configuration of your reverse proxy matches the instructions in the Jenkins documentation. Since you've not mentioned a reverse proxy anywhere in your description, I tested both cases and was unable to duplicate the issue as you describe it, whether I use a reverse proxy or not.

          Mark Waite added a comment - pradeep_m I can't duplicate the issue as you have described it. I can duplicate the issue when I use the wrong URL for the Jenkins controller. Since you state that you are using the correct URL for the Jenkins controller and your URL includes HTTPS and a path ("OSE"), then I assume that you are using a reverse proxy and have configured the reverse proxy to provide HTTPS. Jenkins works very well for me in that configuration. I have a Jenkins controller with an nginx reverse proxy and HTTPS and am able to run java -jar jenkins-cli.jar -s https://home.markwaite.net/jenkins help without any issue. If you are using a reverse proxy, then it is worth confirming that the configuration of your reverse proxy matches the instructions in the Jenkins documentation . Since you've not mentioned a reverse proxy anywhere in your description, I tested both cases and was unable to duplicate the issue as you describe it, whether I use a reverse proxy or not.

          Mark Waite added a comment -

          Closing as "cannot reproduce".

          Mark Waite added a comment - Closing as "cannot reproduce".

            Unassigned Unassigned
            pradeep_m Pradeep
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: