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.

  • Constructor Details

    • HttpRetriever

      @DataBoundConstructor public HttpRetriever(@NonNull String httpURL, @NonNull String credentialsId, boolean preemptiveAuth)
      Constructor
      Parameters:
      httpURL - URL template where the library can be downloaded
      credentialsId - The credentials ID that can be used to do an authenticated download
      preemptiveAuth - 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

      public String getHttpURL()
      Accessor for URL template where the library can be downloaded
      Returns:
      URL template where the library can be downloaded
    • getCredentialsId

      public String 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 Exception
      Retrieves 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 class org.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 retrieved
      run - Jenkins context
      listener - 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 Exception
      Checks first if the library is accessible via a HEAD call. Then retrieves the shared library through HTTP protocol.
      Specified by:
      retrieve in class org.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 used
      target - Where the code should be retrieved
      run - Jenkins context
      listener - Only used to get the logger
      Throws:
      Exception - if the file cannot be downloaded, archive can't be extracted, workspace is not writable
    • validateVersion

      public FormValidation validateVersion(@NonNull String name, @NonNull String version)
      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 class org.jenkinsci.plugins.workflow.libs.LibraryRetriever
      Parameters:
      name - Name of the library
      version - Version of the library
      Returns:
      Result of the validation
    • getDescriptor

      public org.jenkinsci.plugins.workflow.libs.LibraryRetrieverDescriptor getDescriptor()
      Specified by:
      getDescriptor in interface Describable<org.jenkinsci.plugins.workflow.libs.LibraryRetriever>
      Overrides:
      getDescriptor in class org.jenkinsci.plugins.workflow.libs.LibraryRetriever