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 ClassesModifier and TypeClassDescriptionstatic final recordA file archived as a referrer of a build root artifact. -
Method Summary
Modifier and TypeMethodDescriptionvoidarchiveFile(String repository, String tag, String archivedPath, Path localFile) Attach a single archived file as a referrer of the build root artifact.intcopyAllStashes(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.booleanDelete the build root artifact and all its referrers.voiddeleteAllStashes(String repository, String buildTag) Delete all stashes of the given build.voidensureBuildRoot(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.booleanReturn 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.booleanWhether 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.openFile(String repository, RegistryClient.ArchivedFile file) Open a stream to download the content of an archived file.voidpullStash(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.voidpushStash(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.voidtestConnection(String repository) Test the connection to the registry by pushing and deleting a small artifact.
-
Method Details
-
exists
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
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 tagarchivedPath- 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 listedwindow- 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
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:
trueif 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
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
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
Test the connection to the registry by pushing and deleting a small artifact.- Throws:
IOException
-