Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-30978

URLConnection.content.text hangs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Minor Minor
    • pipeline
    • None
    • centos 7 master,
      openjdk8,
      jenkins 1.631
      workflow plugin 1.10

      I have a script I can run via terminal, and via the envinject plugin

      import javax.net.ssl.HostnameVerifier
      import javax.net.ssl.HttpsURLConnection
      import javax.net.ssl.SSLContext
      import javax.net.ssl.TrustManager
      import javax.net.ssl.X509TrustManager
      
      def nullTrustManager = [
          checkClientTrusted: { chain, authType ->  },
          checkServerTrusted: { chain, authType ->  },
          getAcceptedIssuers: { null }
      ]
      
      def nullHostnameVerifier = [
          verify: { hostname, session -> true }
      ]
      
      SSLContext sc = SSLContext.getInstance("SSL")
      sc.init(null, [nullTrustManager as X509TrustManager] as TrustManager[], null)
      HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory())
      HttpsURLConnection.setDefaultHostnameVerifier(nullHostnameVerifier as HostnameVerifier)
      
      URL url = new URL('<my svn https url>');
      URLConnection conn = url.openConnection();
      String basicAuth = "Basic " + <my base 64 encoded user:pass> ;
      conn.setRequestProperty ("Authorization", basicAuth);
      
      svnPageContents = conn.content.text
      regexGroup = (svnPageContents =~ /svn - Revision (\d+):/)
      printf ("found: ${regexGroup[1][1]}")
      

      This just connects to svn to get the latest rev number, on a svn server with a self signed cert. On the console and in envinject this works fine. In the workflow plugin groovy script it exceptions out

      java.lang.NullPointerException: Cannot get property 'text' on null object
      

      So my openConnection is returning null. I don't know why, but it's easy to reproduce

            jglick Jesse Glick
            aflat aflat
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: