All Implemented Interfaces:
ExtensionPoint, Describable<JsonSource>, Serializable

public class RemoteSource extends JsonSource
A JsonSource implementation that retrieves JSON content from a remote HTTP(S) endpoint.

Supports Jenkins proxy configuration automatically via ProxyConfiguration.

Authentication is optional: - If no credentials are provided, a plain HTTP(S) request is sent. - If a credentials ID is provided, the plugin supports: - StandardUsernamePasswordCredentials: Sent as HTTP Basic Auth or Bearer if username is empty. - StringCredentials: Sent as Bearer token in the Authorization header.

The configured URL must return a valid JSON response body. This source type is ideal for external services that expose dynamic data for parameter injection.

Author:
Caner Yanbaz
See Also:
  • Constructor Details

    • RemoteSource

      @DataBoundConstructor public RemoteSource(String url, String credentialsId)
      Constructs a new RemoteSource.
      Parameters:
      url - the remote URL returning JSON content
      credentialsId - optional credentials ID for authentication (username/password)
  • Method Details

    • getUrl

      public String getUrl()
    • getCredentialsId

      public String getCredentialsId()
    • loadJson

      public String loadJson() throws IOException, InterruptedException
      Fetches the JSON content from the configured remote URL using Java's HttpClient.

      - If credentialsId is defined, the appropriate Authorization header is added based on the resolved credentials type (username/password or secret text). - Jenkins global proxy configuration is used automatically. - Throws an IOException if the response code is 400 or higher.

      Specified by:
      loadJson in class JsonSource
      Returns:
      the raw JSON response body as a string
      Throws:
      IOException - if the HTTP request fails or the status code indicates an error
      InterruptedException - if the request is interrupted