• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • cli, core
    • None

      When Jenkins CLI endpoint is reached through URL that redirects to the correct one by 302 HTTP status, following happens (Apache redirecting HTTP to HTTPS):

      Warning: received junk from http://JENKINS_HOST/cli/crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,":",//crumb)
      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
      <html><head>
      <title>302 Found</title>
      </head><body>
      <h1>Found</h1>
      <p>The document has moved <a href="https://JENKINS_HOST/cli/crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,%22:%22,//crumb)">here</a>.</p>
      <hr>
      <address>Apache/2.2.15 (Red Hat) Server at mwqa-jenkins.rhev-ci-vms.eng.rdu2.redhat.com Port 80</address>
      </body></html>
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
        at hudson.cli.FullDuplexHttpStream$CrumbData.getData(FullDuplexHttpStream.java:121)
        at hudson.cli.FullDuplexHttpStream$CrumbData.<init>(FullDuplexHttpStream.java:113)
        at hudson.cli.FullDuplexHttpStream$CrumbData.<init>(FullDuplexHttpStream.java:104)
        at hudson.cli.FullDuplexHttpStream.<init>(FullDuplexHttpStream.java:61)
        at hudson.cli.CLI.connectViaHttp(CLI.java:156)
        at hudson.cli.CLI.<init>(CLI.java:130)
        at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)
        at hudson.cli.CLI._main(CLI.java:471)
        at hudson.cli.CLI.main(CLI.java:387)
      

      Wire interaction:

      010.040.204.174.46296-010.008.063.243.00080: GET /cli/ HTTP/1.1
      User-Agent: Java/1.8.0_131
      Host: JENKINS_HOST
      Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
      Connection: keep-alive
      
      
      010.008.063.243.00080-010.040.204.174.46296: HTTP/1.1 302 Found
      Date: Fri, 19 May 2017 07:43:51 GMT
      Server: Apache/2.2.15 (Red Hat)
      Location: https://JENKINS_HOST/cli/
      Content-Length: 352
      Connection: close
      Content-Type: text/html; charset=iso-8859-1
      
      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
      <html><head>
      <title>302 Found</title>
      </head><body>
      <h1>Found</h1>
      <p>The document has moved <a href="https://JENKINS_HOST/cli/">here</a>.</p>
      <hr>
      <address>Apache/2.2.15 (Red Hat) Server at JENKINS_HOST Port 80</address>
      </body></html>
      
      010.040.204.174.46298-010.008.063.243.00080: GET /cli/crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,":",//crumb) HTTP/1.1
      User-Agent: Java/1.8.0_131
      Host: JENKINS_HOST
      Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
      Connection: keep-alive
      
      
      010.008.063.243.00080-010.040.204.174.46298: HTTP/1.1 302 Found
      Date: Fri, 19 May 2017 07:43:51 GMT
      Server: Apache/2.2.15 (Red Hat)
      Location: https://JENKINS_HOST/cli/crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,%22:%22,//crumb)
      Content-Length: 422
      Connection: close
      Content-Type: text/html; charset=iso-8859-1
      
      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
      <html><head>
      <title>302 Found</title>
      </head><body>
      <h1>Found</h1>
      <p>The document has moved <a href="https://JENKINS_HOST/cli/crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,%22:%22,//crumb)">here</a>.</p>
      <hr>
      <address>Apache/2.2.15 (Red Hat) Server at JENKINS_HOST Port 80</address>
      

          [JENKINS-44361] Jenkins CLI does not follow redirect correctly

          Oliver Gondža added a comment - - edited

          It seems that remoting transport mode performs the redirection except when between different protocols (which seems to security feature of JDK) in which case it complains clearly. EDIT: It does not, it was just picking the port number header from the redirect page and then continued on TCP level...

          Ssh transport mode does not follow redirects and complain about missing port. Http transport fails with the attached exception (after not following the redirect).

          Oliver Gondža added a comment - - edited It seems that remoting transport mode performs the redirection except when between different protocols (which seems to security feature of JDK) in which case it complains clearly. EDIT: It does not, it was just picking the port number header from the redirect page and then continued on TCP level... Ssh transport mode does not follow redirects and complain about missing port. Http transport fails with the attached exception (after not following the redirect).

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          cli/src/main/java/hudson/cli/CLI.java
          cli/src/main/java/hudson/cli/FullDuplexHttpStream.java
          cli/src/main/java/hudson/cli/SSHCLI.java
          test/src/test/java/hudson/cli/CLITest.java
          http://jenkins-ci.org/commit/jenkins/741be05517eb5158bb2f273fe077c57ab7448006
          Log:
          [FIXED JENKINS-44361] Follow HTTP redirects while initiating CLI connection

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: cli/src/main/java/hudson/cli/CLI.java cli/src/main/java/hudson/cli/FullDuplexHttpStream.java cli/src/main/java/hudson/cli/SSHCLI.java test/src/test/java/hudson/cli/CLITest.java http://jenkins-ci.org/commit/jenkins/741be05517eb5158bb2f273fe077c57ab7448006 Log: [FIXED JENKINS-44361] Follow HTTP redirects while initiating CLI connection

          Oleg Nenashev added a comment -

          It has been fixed in 2.68

          Oleg Nenashev added a comment - It has been fixed in 2.68

          I have seen a similar issue with the install-plugin command recently, In Jenkins 2.186. See https://issues.jenkins-ci.org/browse/JENKINS-29065.

          Allan BURDAJEWICZ added a comment - I have seen a similar issue with the install-plugin command recently, In Jenkins 2.186. See https://issues.jenkins-ci.org/browse/JENKINS-29065 .

          Jesse Glick added a comment -

          That is unrelated.

          Jesse Glick added a comment - That is unrelated.

            Unassigned Unassigned
            olivergondza Oliver Gondža
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: