Class RemoteSource
- All Implemented Interfaces:
ExtensionPoint, Describable<JsonSource>, Serializable
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.
- 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDescriptor for theRemoteSource, used to display this option in the Jenkins UI dropdown.Nested classes/interfaces inherited from interface ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
ConstructorsConstructorDescriptionRemoteSource(String url, String credentialsId) Constructs a newRemoteSource. -
Method Summary
Modifier and TypeMethodDescriptiongetUrl()loadJson()Fetches the JSON content from the configured remote URL using Java'sHttpClient.Methods inherited from class JsonSource
loadOptionsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Describable
getDescriptor
-
Constructor Details
-
RemoteSource
Constructs a newRemoteSource.- Parameters:
url- the remote URL returning JSON contentcredentialsId- optional credentials ID for authentication (username/password)
-
-
Method Details
-
getUrl
-
getCredentialsId
-
loadJson
Fetches the JSON content from the configured remote URL using Java'sHttpClient.- If
credentialsIdis 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 anIOExceptionif the response code is 400 or higher.- Specified by:
loadJsonin classJsonSource- Returns:
- the raw JSON response body as a string
- Throws:
IOException- if the HTTP request fails or the status code indicates an errorInterruptedException- if the request is interruptedIllegalArgumentException- if the credentials ID is invalid or not found
-