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 ofSCMFileSystem
.- Since:
- 3.0.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GitSCMFileSystem.BuilderImpl
static interface
GitSCMFileSystem.FSFunction<V>
Simple callback that is used withinvoke(jenkins.plugins.git.GitSCMFileSystem.FSFunction)
in order to provide a locked view of the Git repository
-
Constructor Summary
Constructors Modifier Constructor Description protected
GitSCMFileSystem(org.jenkinsci.plugins.gitclient.GitClient client, String remote, String head, AbstractGitSCMSource.SCMRevisionImpl rev)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 anGitSCMFileSystem.FSFunction
callback with a singleton repository cache lock.long
lastModified()
-
-
-
Constructor Detail
-
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 Detail
-
getRevision
public AbstractGitSCMSource.SCMRevisionImpl getRevision()
- Overrides:
getRevision
in classjenkins.scm.api.SCMFileSystem
-
lastModified
public long lastModified() throws IOException, InterruptedException
- 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
-
-