Class RegistryClient

java.lang.Object
io.jenkins.plugins.oras_artifacts.RegistryClient

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final class RegistryClient extends Object
Wraps a Registry
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    A file archived as a referrer of a build root artifact.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    archiveFile(String repository, String tag, String archivedPath, Path localFile)
    Attach a single archived file as a referrer of the build root artifact.
    int
    copyAllStashes(String repository, String buildTag, io.jenkins.plugins.oras_artifacts.BuildOwner owner, String targetRepository, String targetBuildTag, io.jenkins.plugins.oras_artifacts.BuildOwner targetOwner)
    Copy all stashes of a build to another build.
    boolean
    delete(String repository, String tag, io.jenkins.plugins.oras_artifacts.BuildOwner owner)
    Delete the build root artifact and all its referrers.
    void
    deleteAllStashes(String repository, String buildTag)
    Delete all stashes of the given build.
    void
    ensureBuildRoot(String repository, String tag, io.jenkins.plugins.oras_artifacts.BuildOwner owner)
    Ensure the build root artifact exists for the given repository/tag, creating it if needed.
    boolean
    exists(String repository, String tag)
    Return whether a manifest exists for the given repository/tag.
    findArchivedFile(String repository, String tag, io.jenkins.plugins.oras_artifacts.BuildOwner owner, io.jenkins.plugins.oras_artifacts.RegistryClient.CreatedWindow window, String path)
    Find a single archived file by its path.
    boolean
    hasStash(String repository, String buildTag, String name)
    Whether a stash exists for the given build.
    listArchivedFiles(String repository, String tag, io.jenkins.plugins.oras_artifacts.BuildOwner owner, io.jenkins.plugins.oras_artifacts.RegistryClient.CreatedWindow window)
    List all files archived for the given repository/tag by querying the OCI referrers API of the build root artifact digest.
    Open a stream to download the content of an archived file.
    void
    pullStash(String repository, String buildTag, io.jenkins.plugins.oras_artifacts.BuildOwner owner, String name, Path target)
    Pull the content of a stash of the given build to the given target file.
    void
    pushStash(String repository, String buildTag, io.jenkins.plugins.oras_artifacts.BuildOwner owner, String name, Path tarGz)
    Push a stash (a single tar.gz artifact) of the given build under the given repository/name.
    void
    testConnection(String repository)
    Test the connection to the registry by pushing and deleting a small artifact.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • exists

      public boolean exists(String repository, String tag)
      Return whether a manifest exists for the given repository/tag.
    • ensureBuildRoot

      public void ensureBuildRoot(String repository, String tag, io.jenkins.plugins.oras_artifacts.BuildOwner owner) throws AbortException
      Ensure the build root artifact exists for the given repository/tag, creating it if needed.
      Throws:
      AbortException - if the existing build root belongs to another build
    • archiveFile

      public void archiveFile(String repository, String tag, String archivedPath, Path localFile)
      Attach a single archived file as a referrer of the build root artifact.
      Parameters:
      repository - the repository (sanitized job full name)
      tag - the build root tag
      archivedPath - the archived path, relative to the artifacts root (e.g. "dir/file.txt")
      localFile - the local file to upload
    • listArchivedFiles

      public List<RegistryClient.ArchivedFile> listArchivedFiles(String repository, String tag, io.jenkins.plugins.oras_artifacts.BuildOwner owner, @CheckForNull io.jenkins.plugins.oras_artifacts.RegistryClient.CreatedWindow window)
      List all files archived for the given repository/tag by querying the OCI referrers API of the build root artifact digest.
      Parameters:
      owner - the build the root artifact must belong to, otherwise nothing is listed
      window - if set, only list files created within this window
    • findArchivedFile

      public Optional<RegistryClient.ArchivedFile> findArchivedFile(String repository, String tag, io.jenkins.plugins.oras_artifacts.BuildOwner owner, @CheckForNull io.jenkins.plugins.oras_artifacts.RegistryClient.CreatedWindow window, String path)
      Find a single archived file by its path.
      See Also:
    • openFile

      public InputStream openFile(String repository, RegistryClient.ArchivedFile file)
      Open a stream to download the content of an archived file.
    • delete

      public boolean delete(String repository, String tag, io.jenkins.plugins.oras_artifacts.BuildOwner owner)
      Delete the build root artifact and all its referrers.
      Parameters:
      owner - the build the root artifact must belong to, otherwise nothing is deleted
      Returns:
      true if something was deleted
    • pushStash

      public void pushStash(String repository, String buildTag, io.jenkins.plugins.oras_artifacts.BuildOwner owner, String name, Path tarGz)
      Push a stash (a single tar.gz artifact) of the given build under the given repository/name.
      Parameters:
      buildTag - the tag of the build root artifact of the build owning the stash
    • hasStash

      public boolean hasStash(String repository, String buildTag, String name)
      Whether a stash exists for the given build.
    • pullStash

      public void pullStash(String repository, String buildTag, io.jenkins.plugins.oras_artifacts.BuildOwner owner, String name, Path target) throws AbortException
      Pull the content of a stash of the given build to the given target file.
      Throws:
      AbortException - if the stash belongs to another build
    • deleteAllStashes

      public void deleteAllStashes(String repository, String buildTag)
      Delete all stashes of the given build.
    • copyAllStashes

      public int copyAllStashes(String repository, String buildTag, io.jenkins.plugins.oras_artifacts.BuildOwner owner, String targetRepository, String targetBuildTag, io.jenkins.plugins.oras_artifacts.BuildOwner targetOwner) throws IOException
      Copy all stashes of a build to another build.
      Returns:
      the number of copied stashes
      Throws:
      IOException
    • testConnection

      public void testConnection(String repository) throws IOException
      Test the connection to the registry by pushing and deleting a small artifact.
      Throws:
      IOException