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 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Descriptor for theRemoteSource
, used to display this option in the Jenkins UI dropdown.Nested classes/interfaces inherited from interface hudson.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 com.github.cyanbaz.jenkins.plugins.jsonparameter.JsonSource
loadOptions
Methods inherited from class hudson.model.AbstractDescribableImpl
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
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 anIOException
if the response code is 400 or higher.- Specified by:
loadJson
in 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 interrupted
-