Package jenkins.plugins.git
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfaceSimple callback that is used withinvoke(jenkins.plugins.git.GitSCMFileSystem.FSFunction)in order to provide a locked view of the Git repositoryNested classes/interfaces inherited from class jenkins.scm.api.SCMFileSystem
jenkins.scm.api.SCMFileSystem.Builder -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGitSCMFileSystem(org.jenkinsci.plugins.gitclient.GitClient client, String remote, String head, AbstractGitSCMSource.SCMRevisionImpl rev) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanchangesSince(jenkins.scm.api.SCMRevision revision, OutputStream changeLogStream) jenkins.scm.api.SCMFilegetRoot()<V> Vinvoke(GitSCMFileSystem.FSFunction<V> function) Called with anGitSCMFileSystem.FSFunctioncallback with a singleton repository cache lock.longMethods inherited from class jenkins.scm.api.SCMFileSystem
child, close, isFixedRevision, of, of, of, of, of, supports, supports, supports, supports
-
Constructor Details
-
GitSCMFileSystem
protected GitSCMFileSystem(org.jenkinsci.plugins.gitclient.GitClient client, String remote, String head, @CheckForNull AbstractGitSCMSource.SCMRevisionImpl rev) throws IOException, InterruptedException Constructor.- Parameters:
client- the clientremote- the remote GIT URLhead- identifier for the head commit to be referencedrev- the revision.- Throws:
IOException- on I/O errorInterruptedException- on thread interruption
-
-
Method Details
-
getRevision
- Overrides:
getRevisionin classjenkins.scm.api.SCMFileSystem
-
lastModified
- Specified by:
lastModifiedin classjenkins.scm.api.SCMFileSystem- Throws:
IOExceptionInterruptedException
-
getRoot
@NonNull public jenkins.scm.api.SCMFile getRoot()- Specified by:
getRootin classjenkins.scm.api.SCMFileSystem
-
invoke
public <V> V invoke(GitSCMFileSystem.FSFunction<V> function) throws IOException, InterruptedException Called with anGitSCMFileSystem.FSFunctioncallback 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 errorInterruptedException- if interrupted
-
changesSince
public boolean changesSince(@CheckForNull jenkins.scm.api.SCMRevision revision, @NonNull OutputStream changeLogStream) throws UnsupportedOperationException, IOException, InterruptedException - Overrides:
changesSincein classjenkins.scm.api.SCMFileSystem- Throws:
UnsupportedOperationExceptionIOExceptionInterruptedException
-