Class GitSCMFileSystem

java.lang.Object
jenkins.scm.api.SCMFileSystem
jenkins.plugins.git.GitSCMFileSystem
All Implemented Interfaces:
Closeable, AutoCloseable

public class GitSCMFileSystem extends jenkins.scm.api.SCMFileSystem
Base implementation of SCMFileSystem.
Since:
3.0.2
  • Constructor Details

  • Method Details

    • getRevision

      Overrides:
      getRevision in class jenkins.scm.api.SCMFileSystem
    • lastModified

      public long lastModified() throws IOException, InterruptedException
      Specified by:
      lastModified in class jenkins.scm.api.SCMFileSystem
      Throws:
      IOException
      InterruptedException
    • getRoot

      @NonNull public jenkins.scm.api.SCMFile getRoot()
      Specified by:
      getRoot in class jenkins.scm.api.SCMFileSystem
    • invoke

      public <V> V invoke(GitSCMFileSystem.FSFunction<V> function) throws IOException, InterruptedException
      Called with an GitSCMFileSystem.FSFunction callback with a singleton repository cache lock. An example usage might be:
      
            return fs.invoke(new GitSCMFileSystem.FSFunction<byte[]>() {
                public byte[] invoke(Repository repository) throws IOException, InterruptedException {
                    Git activeRepo = getClonedRepository(repository);
                    File repoDir = activeRepo.getRepository().getDirectory().getParentFile();
                    System.out.println("Repo cloned to: " + repoDir.getCanonicalPath());
                    try {
                        File f = new File(repoDir, filePath);
                        if (f.canRead()) {
                            return IOUtils.toByteArray(new FileInputStream(f));
                        }
                        return null;
                    } finally {
                        FileUtils.deleteDirectory(repoDir);
                    }
                }
            });
       
      Type Parameters:
      V - return type
      Parameters:
      function - callback executed with a locked repository
      Returns:
      whatever you return from the provided function
      Throws:
      IOException - if there is an I/O error
      InterruptedException - if interrupted
    • changesSince

      public boolean changesSince(@CheckForNull jenkins.scm.api.SCMRevision revision, @NonNull OutputStream changeLogStream) throws UnsupportedOperationException, IOException, InterruptedException
      Overrides:
      changesSince in class jenkins.scm.api.SCMFileSystem
      Throws:
      UnsupportedOperationException
      IOException
      InterruptedException