Class ArtifactoryClient

java.lang.Object
io.jenkins.plugins.jobcacher.artifactory.ArtifactoryClient
All Implemented Interfaces:
AutoCloseable

public class ArtifactoryClient extends Object implements AutoCloseable
  • Field Details

    • LOGGER

      public static final org.slf4j.Logger LOGGER
  • Constructor Details

    • ArtifactoryClient

      public ArtifactoryClient(@NonNull String serverUrl, @NonNull String repository, @NonNull com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials credentials)
    • ArtifactoryClient

      public ArtifactoryClient(@NonNull ArtifactoryClient.ArtifactoryConfig config)
  • Method Details

    • getConfig

    • uploadArtifact

      public void uploadArtifact(Path file, String targetPath) throws IOException
      Upload an artifact to the repository
      Parameters:
      file - the file to upload
      targetPath - the path to upload the file to
      Throws:
      IOException - if the file cannot be uploaded
    • deleteArtifact

      public void deleteArtifact(String targetPath)
      Delete an artifact or path from the repository
      Parameters:
      targetPath - the path of the artifact to delete
    • move

      public void move(String sourcePath, String targetPath)
      Move an artifact from one path to another. Require Artifactory PRO
      Parameters:
      sourcePath - the source path
      targetPath - the target path
    • copy

      public void copy(String sourcePath, String targetPath)
      Copy an artifact from one path to another. Require Artifactory PRO
      Parameters:
      sourcePath - the source path
      targetPath - the target path
    • downloadArtifact

      public InputStream downloadArtifact(String targetPath) throws IOException
      Download an artifact from the repository
      Parameters:
      targetPath - the path of the artifact to download
      Returns:
      a pair of the closable client and the input stream of the artifact
      Throws:
      IOException - if the artifact cannot be downloaded
    • isFolder

      public boolean isFolder(String targetPath) throws IOException
      Check if a path is a folder
      Parameters:
      targetPath - the path to check
      Returns:
      true if the path is a folder, false otherwise
      Throws:
      IOException - if the path cannot be checked
    • list

      public List<String> list(String targetPath) throws IOException
      List the files in a folder
      Parameters:
      targetPath - the path to list
      Returns:
      the list of files in the folder
      Throws:
      IOException - if the files cannot be listed
    • isFile

      public boolean isFile(String targetPath) throws IOException
      Check if a path is a file
      Parameters:
      targetPath - the path to check
      Returns:
      true if the path is a file, false otherwise
      Throws:
      IOException - if the path cannot be checked
    • lastUpdated

      public long lastUpdated(String targetPath) throws IOException
      Get the last updated time of a path
      Parameters:
      targetPath - the path to check
      Returns:
      the last updated time of the path
      Throws:
      IOException - if the last updated time cannot be checked
    • size

      public long size(String targetPath) throws IOException
      Get the size of a path
      Parameters:
      targetPath - the path to check
      Returns:
      the size of the path
      Throws:
      IOException - if the size cannot be checked
    • buildArtifactoryConfig

      public ArtifactoryClient.ArtifactoryConfig buildArtifactoryConfig()
      Return a new ArtifactoryConfig object for this client
      Returns:
      the ArtifactoryConfig object
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception