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
Modifier and TypeClassDescriptionstatic class
static interface
Simple 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
ModifierConstructorDescriptionprotected
GitSCMFileSystem
(org.jenkinsci.plugins.gitclient.GitClient client, String remote, String head, AbstractGitSCMSource.SCMRevisionImpl rev) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
changesSince
(jenkins.scm.api.SCMRevision revision, OutputStream changeLogStream) jenkins.scm.api.SCMFile
getRoot()
<V> V
invoke
(GitSCMFileSystem.FSFunction<V> function) Called with anGitSCMFileSystem.FSFunction
callback with a singleton repository cache lock.long
Methods 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:
getRevision
in classjenkins.scm.api.SCMFileSystem
-
lastModified
- Specified by:
lastModified
in classjenkins.scm.api.SCMFileSystem
- Throws:
IOException
InterruptedException
-
getRoot
@NonNull public jenkins.scm.api.SCMFile getRoot()- Specified by:
getRoot
in classjenkins.scm.api.SCMFileSystem
-
invoke
public <V> V invoke(GitSCMFileSystem.FSFunction<V> function) throws IOException, InterruptedException Called with anGitSCMFileSystem.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 errorInterruptedException
- if interrupted
-
changesSince
public boolean changesSince(@CheckForNull jenkins.scm.api.SCMRevision revision, @NonNull OutputStream changeLogStream) throws UnsupportedOperationException, IOException, InterruptedException - Overrides:
changesSince
in classjenkins.scm.api.SCMFileSystem
- Throws:
UnsupportedOperationException
IOException
InterruptedException
-