Class HttpRetriever
java.lang.Object
hudson.model.AbstractDescribableImpl<org.jenkinsci.plugins.workflow.libs.LibraryRetriever>
org.jenkinsci.plugins.workflow.libs.LibraryRetriever
com.amadeus.jenkins.plugins.workflow.libs.HttpRetriever
- All Implemented Interfaces:
ExtensionPoint
,Describable<org.jenkinsci.plugins.workflow.libs.LibraryRetriever>
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public class HttpRetriever
extends org.jenkinsci.plugins.workflow.libs.LibraryRetriever
The goal of this plugin is to provide another way to retrieve shared libraries via the @Library declaration
in a Jenkinsfile.
The current official plugin (workflow-cps-global-lib) does provide only a way to retrieve shared libraries through a SCM, such as Git, Subversion, etc.
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
ConstructorDescriptionHttpRetriever
(String httpURL, String credentialsId, boolean preemptiveAuth) Constructor -
Method Summary
Modifier and TypeMethodDescriptionAccessor for credentials ID that can be used to do an authenticated downloadorg.jenkinsci.plugins.workflow.libs.LibraryRetrieverDescriptor
Accessor for URL template where the library can be downloadedboolean
Accessor for know if the plugin should send the basic authentication response before the server gives an unauthorized responsevoid
retrieve
(String name, String version, boolean changelog, FilePath target, Run<?, ?> run, TaskListener listener) Checks first if the library is accessible via a HEAD call.void
Retrieves the shared library code.validateVersion
(String name, String version) Validates version.Methods inherited from class org.jenkinsci.plugins.workflow.libs.LibraryRetriever
validateVersion
-
Constructor Details
-
HttpRetriever
@DataBoundConstructor public HttpRetriever(@NonNull String httpURL, @NonNull String credentialsId, boolean preemptiveAuth) Constructor- Parameters:
httpURL
- URL template where the library can be downloadedcredentialsId
- The credentials ID that can be used to do an authenticated downloadpreemptiveAuth
- Send the basic authentication response before the server gives an unauthorized response
-
-
Method Details
-
isPreemptiveAuth
public boolean isPreemptiveAuth()Accessor for know if the plugin should send the basic authentication response before the server gives an unauthorized response- Returns:
- if the plugin should always send the basic authentication
-
getHttpURL
Accessor for URL template where the library can be downloaded- Returns:
- URL template where the library can be downloaded
-
getCredentialsId
Accessor for credentials ID that can be used to do an authenticated download- Returns:
- The credentials ID that can be used to do an authenticated download
-
retrieve
public void retrieve(@NonNull String name, @NonNull String version, @NonNull FilePath target, @NonNull Run<?, ?> run, @NonNull TaskListener listener) throws ExceptionRetrieves the shared library code. Prefer this version of the method.Checks first if the library is accessible via a HEAD call. Then retrieves the shared library through HTTP protocol.
- Specified by:
retrieve
in classorg.jenkinsci.plugins.workflow.libs.LibraryRetriever
- Parameters:
name
- Name of the library (as specified in the Jenkinsfile @Library)version
- Version of the library (as specified in the Jenkinsfile @Library)target
- Where the code should be retrievedrun
- Jenkins contextlistener
- Only used to get the logger- Throws:
Exception
- if the file cannot be downloaded, archive can't be extracted, workspace is not writable
-
retrieve
public void retrieve(@NonNull String name, @NonNull String version, @NonNull boolean changelog, @NonNull FilePath target, @NonNull Run<?, ?> run, @NonNull TaskListener listener) throws ExceptionChecks first if the library is accessible via a HEAD call. Then retrieves the shared library through HTTP protocol.- Specified by:
retrieve
in classorg.jenkinsci.plugins.workflow.libs.LibraryRetriever
- Parameters:
name
- Name of the library (as specified in the Jenkinsfile @Library)version
- Version of the library (as specified in the Jenkinsfile @Library)changelog
- Not usedtarget
- Where the code should be retrievedrun
- Jenkins contextlistener
- Only used to get the logger- Throws:
Exception
- if the file cannot be downloaded, archive can't be extracted, workspace is not writable
-
validateVersion
Validates version. Is it available for download. Tests the URL. Used if a default version is referenced in the declaration of the library. Then the archive of the library must be reachable.Replaces the pattern ${library.NAME.version} in the URL (if found in the shared library URL) either by the default version specified in the admin configuration page or by the user in the Jenkinsfile @Library call.
- Overrides:
validateVersion
in classorg.jenkinsci.plugins.workflow.libs.LibraryRetriever
- Parameters:
name
- Name of the libraryversion
- Version of the library- Returns:
- Result of the validation
-
getDescriptor
public org.jenkinsci.plugins.workflow.libs.LibraryRetrieverDescriptor getDescriptor()- Specified by:
getDescriptor
in interfaceDescribable<org.jenkinsci.plugins.workflow.libs.LibraryRetriever>
- Overrides:
getDescriptor
in classorg.jenkinsci.plugins.workflow.libs.LibraryRetriever
-