public class GitSCMFileSystem extends jenkins.scm.api.SCMFileSystem
SCMFileSystem.| Modifier and Type | Class and Description |
|---|---|
static class |
GitSCMFileSystem.BuilderImpl |
static interface |
GitSCMFileSystem.FSFunction<V>
Simple callback that is used with
invoke(jenkins.plugins.git.GitSCMFileSystem.FSFunction)
in order to provide a locked view of the Git repository |
jenkins.scm.api.SCMFileSystem.Builder| Modifier | Constructor and Description |
|---|---|
protected |
GitSCMFileSystem(org.jenkinsci.plugins.gitclient.GitClient client,
String remote,
String head,
AbstractGitSCMSource.SCMRevisionImpl rev)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
changesSince(jenkins.scm.api.SCMRevision revision,
OutputStream changeLogStream) |
AbstractGitSCMSource.SCMRevisionImpl |
getRevision() |
jenkins.scm.api.SCMFile |
getRoot() |
<V> V |
invoke(GitSCMFileSystem.FSFunction<V> function)
Called with an
GitSCMFileSystem.FSFunction callback with a singleton repository
cache lock. |
long |
lastModified() |
child, close, isFixedRevision, of, of, of, of, supports, supports, supports, supportsprotected GitSCMFileSystem(org.jenkinsci.plugins.gitclient.GitClient client,
String remote,
String head,
@CheckForNull
AbstractGitSCMSource.SCMRevisionImpl rev)
throws IOException,
InterruptedException
client - the clientremote - the remote GIT URLhead - identifier for the head commit to be referencedrev - the revision.IOException - on I/O errorInterruptedException - on thread interruptionpublic AbstractGitSCMSource.SCMRevisionImpl getRevision()
getRevision in class jenkins.scm.api.SCMFileSystempublic long lastModified()
throws IOException,
InterruptedException
lastModified in class jenkins.scm.api.SCMFileSystemIOExceptionInterruptedException@NonNull public jenkins.scm.api.SCMFile getRoot()
getRoot in class jenkins.scm.api.SCMFileSystempublic <V> V invoke(GitSCMFileSystem.FSFunction<V> function) throws IOException, InterruptedException
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);
}
}
});
V - return typefunction - callback executed with a locked repositoryIOException - if there is an I/O errorInterruptedException - if interruptedpublic boolean changesSince(@CheckForNull
jenkins.scm.api.SCMRevision revision,
@NonNull
OutputStream changeLogStream)
throws UnsupportedOperationException,
IOException,
InterruptedException
changesSince in class jenkins.scm.api.SCMFileSystemUnsupportedOperationExceptionIOExceptionInterruptedExceptionCopyright © 2007–2021. All rights reserved.