A Jenkins plugin making an outbound HTTP request can use Jenkins' public proxy-aware client helper:

HttpClient client = ProxyConfiguration.newHttpClient();
HttpRequest request = ProxyConfiguration.newHttpRequestBuilder(
        URI.create("https://service.example/status"))
    .GET()
    .build();
HttpResponse<Void> response = client.send(
    request, HttpResponse.BodyHandlers.discarding());

The fragment uses hudson.ProxyConfiguration, java.net.URI and java.net.http types. The caller handles I/O and interruption through its normal plugin flow. The body handler consumes and discards the response body.

newHttpClient and its builder interface have been available since Jenkins 2.379. In a controller JVM, they apply Jenkins' supported proxy configuration. Reuse the client for its intended work rather than creating one for every request.

That avoids copying the controller's stored proxy name and password into an independently configured transport. A separately created Java HTTP client does not become proxy-aware just because the controller UI has a proxy entry.

For requests that supply a destination Authorization header, review the helper's documented authenticated-proxy limitation on Java 17 and later. The Javadoc calls out that combination specifically; selecting this helper does not remove that client limitation.

Ũhoro ũhĩtĩte