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

Notifications Plugin does not honor the "http_proxy" environment variable

      My CI/CD environment is behind a proxy and can't access the network. I'm using Zapier to notify a Yammer group of our Build status. Here's the request that times out because of the lack of connectivity.

      Started by user mdesales
      Notifying endpoint 'HTTP:https://zapier.com/hooks/catch/o54xyk/'
      ERROR: Failed to notify endpoint 'HTTP:https://zapier.com/hooks/catch/o54xyk/'
      java.net.SocketTimeoutException: connect timed out
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      at java.net.Socket.connect(Socket.java:579)
      at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618)
      at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
      at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:275)
      at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
      at com.tikal.hudson.plugins.notification.Protocol$3.send(Protocol.java:69)
      at com.tikal.hudson.plugins.notification.Phase.handle(Phase.java:42)
      at com.tikal.hudson.plugins.notification.JobListener.onStarted(JobListener.java:31)
      at hudson.model.listeners.RunListener.fireStarted(RunListener.java:213)
      at hudson.model.Run.execute(Run.java:1741)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:89)
      at hudson.model.Executor.run(Executor.java:240)
      Failed to notify endpoint 'HTTP:https://zapier.com/hooks/catch/o54xyk/' - java.net.SocketTimeoutException: connect timed out
      Building in workspace /app/installs/jenkins/jobs/Status Notification/workspace
      Notifying endpoint 'HTTP:https://zapier.com/hooks/catch/o54xyk/'
      ERROR: Failed to notify endpoint 'HTTP:https://zapier.com/hooks/catch/o54xyk/'
      java.net.SocketTimeoutException: connect timed out
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      at java.net.Socket.connect(Socket.java:579)
      at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618)
      at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
      at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:275)
      at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
      at com.tikal.hudson.plugins.notification.Protocol$3.send(Protocol.java:69)
      at com.tikal.hudson.plugins.notification.Phase.handle(Phase.java:42)
      at com.tikal.hudson.plugins.notification.JobListener.onCompleted(JobListener.java:36)
      at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:199)
      at hudson.model.Run.execute(Run.java:1796)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:89)
      at hudson.model.Executor.run(Executor.java:240)
      Failed to notify endpoint 'HTTP:https://zapier.com/hooks/catch/o54xyk/' - java.net.SocketTimeoutException: connect timed out
      Finished: SUCCESS

          [JENKINS-25558] Notifications Plugin does not honor the "http_proxy" environment variable

          Alright... I have created a pull request with the fix...

          https://github.com/jenkinsci/notification-plugin/pull/16

          I'm taking the URL from the "http_proxy" environment variable and decorating the connection with a Proxy instance before the request. The notification to Zapier worked as expected:

          Started by user mdesales
          Notifying endpoint 'HTTP:https://zapier.com/hooks/catch/o54xyk/'
          Building in workspace /app/installs/jenkins/jobs/Status Notification/workspace
          Notifying endpoint 'HTTP:https://zapier.com/hooks/catch/o54xyk/'
          Finished: SUCCESS

          Thanks!

          (Say hi to Kosuke, from Marcello)...

          Marcello de Sales added a comment - Alright... I have created a pull request with the fix... https://github.com/jenkinsci/notification-plugin/pull/16 I'm taking the URL from the "http_proxy" environment variable and decorating the connection with a Proxy instance before the request. The notification to Zapier worked as expected: Started by user mdesales Notifying endpoint 'HTTP: https://zapier.com/hooks/catch/o54xyk/ ' Building in workspace /app/installs/jenkins/jobs/Status Notification/workspace Notifying endpoint 'HTTP: https://zapier.com/hooks/catch/o54xyk/ ' Finished: SUCCESS Thanks! (Say hi to Kosuke, from Marcello)...

          Please verify this... At least it works for me... Unfortunately, I'm not providing test cases...

          Marcello de Sales added a comment - Please verify this... At least it works for me... Unfortunately, I'm not providing test cases...

          Code changed in jenkins
          User: Marcello de Sales
          Path:
          src/main/java/com/tikal/hudson/plugins/notification/Protocol.java
          http://jenkins-ci.org/commit/notification-plugin/da26771d3d37fa77c26345ac7ab35529a9eef31a
          Log:
          JENKINS-25558: Notifications Plugin does not honor the "http_proxy" environment variable: Fix

          This commit partially fixes the problem by using an HTTP Proxy without authentication. In
          addition, it does not provide test cases, but it does work properly. The message after using
          a new build of this plugin was as follows:

          Started by user mdesales
          Notifying endpoint 'HTTP:https://zapier.com/hooks/catch/o54xyk/'
          Building in workspace /app/installs/jenkins/jobs/Status Notification/workspace
          Notifying endpoint 'HTTP:https://zapier.com/hooks/catch/o54xyk/'
          Finished: SUCCESS

          (Sorry, in a rush to get things done and I can try providing a test with an internal
          http proxy server).

          • modified: src/main/java/com/tikal/hudson/plugins/notification/Protocol.java
          • Verifying if the environment variable "http_proxy" is set. If so, decorate the connection
            with the proxy information before making the HTTP request.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marcello de Sales Path: src/main/java/com/tikal/hudson/plugins/notification/Protocol.java http://jenkins-ci.org/commit/notification-plugin/da26771d3d37fa77c26345ac7ab35529a9eef31a Log: JENKINS-25558 : Notifications Plugin does not honor the "http_proxy" environment variable: Fix This commit partially fixes the problem by using an HTTP Proxy without authentication. In addition, it does not provide test cases, but it does work properly. The message after using a new build of this plugin was as follows: Started by user mdesales Notifying endpoint 'HTTP: https://zapier.com/hooks/catch/o54xyk/ ' Building in workspace /app/installs/jenkins/jobs/Status Notification/workspace Notifying endpoint 'HTTP: https://zapier.com/hooks/catch/o54xyk/ ' Finished: SUCCESS (Sorry, in a rush to get things done and I can try providing a test with an internal http proxy server). modified: src/main/java/com/tikal/hudson/plugins/notification/Protocol.java Verifying if the environment variable "http_proxy" is set. If so, decorate the connection with the proxy information before making the HTTP request.

          Code changed in jenkins
          User: Haggai Philip Zagury
          Path:
          src/main/java/com/tikal/hudson/plugins/notification/Protocol.java
          http://jenkins-ci.org/commit/notification-plugin/c5c81d049fb7d2b7bcd17f539825e74c55194476
          Log:
          Merge pull request #16 from marcellodesales/master

          JENKINS-25558: Notifications Plugin does not honor the "http_proxy" env Variable

          Compare: https://github.com/jenkinsci/notification-plugin/compare/d3d00a547eed...c5c81d049fb7

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Haggai Philip Zagury Path: src/main/java/com/tikal/hudson/plugins/notification/Protocol.java http://jenkins-ci.org/commit/notification-plugin/c5c81d049fb7d2b7bcd17f539825e74c55194476 Log: Merge pull request #16 from marcellodesales/master JENKINS-25558 : Notifications Plugin does not honor the "http_proxy" env Variable Compare: https://github.com/jenkinsci/notification-plugin/compare/d3d00a547eed...c5c81d049fb7

            Unassigned Unassigned
            marcellodesales Marcello de Sales
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: