Package org.jenkinsci.plugins.gitserver
Class FileBackedHttpGitRepository
java.lang.Object
org.jenkinsci.plugins.gitserver.HttpGitRepository
org.jenkinsci.plugins.gitserver.FileBackedHttpGitRepository
Convenient subtype of
HttpGitRepository where the repository
is non-bare, resides in a directory local to the controller, and you maintain
the local up-to-date checkout whenever a change is pushed.- Author:
- Kohsuke Kawaguchi
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFileBackedHttpGitRepository(File workspace) protectedFileBackedHttpGitRepository(Path workspace) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidDo something likeJenkins.getInstance().checkPermission(Jenkins.ADMINISTER)to make sure the user has the permission to push.protected voidcreateInitialRepository(org.eclipse.jgit.lib.Repository r) Called when there's no .git directory to create one.org.eclipse.jgit.transport.ReceivePackcreateReceivePack(jakarta.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db) Requires the admin access to be able to pushorg.eclipse.jgit.transport.ReceivePackcreateReceivePack(org.eclipse.jgit.lib.Repository db) org.eclipse.jgit.transport.UploadPackcreateUploadPack(jakarta.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db) This default implementation allows read access to anyone who can access the HTTP URL this repository is bound to.org.eclipse.jgit.lib.RepositoryOpens the repository this UI-bound object holds on to.protected voidupdateWorkspace(org.eclipse.jgit.lib.Repository repo) Called when new ref is pushed to update the local workspace.Methods inherited from class org.jenkinsci.plugins.gitserver.HttpGitRepository
checkPullPermission, createReceivePack, createUploadPack, doDynamic, init
-
Field Details
-
workspace
Directory of the local workspace on the controller. There will be "./.git" that hosts the actual repository.
-
-
Constructor Details
-
FileBackedHttpGitRepository
-
FileBackedHttpGitRepository
-
-
Method Details
-
openRepository
Description copied from class:HttpGitRepositoryOpens the repository this UI-bound object holds on to.- Specified by:
openRepositoryin classHttpGitRepository- Throws:
IOException
-
createInitialRepository
Called when there's no .git directory to create one.This implementation also imports whatever currently in there into the repository.
- Throws:
IOException
-
createUploadPack
public org.eclipse.jgit.transport.UploadPack createUploadPack(jakarta.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db) throws org.eclipse.jgit.transport.resolver.ServiceNotEnabledException, org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException This default implementation allows read access to anyone who can access the HTTP URL this repository is bound to.For example, if this object is used as a project action, and the project isn't readable to Alice, then Alice won't be able to pull from this repository (think of a POSIX file system where /foo/bar is rwx------ and /foo/bar/zot is rwxrwxrwx.)
- Overrides:
createUploadPackin classHttpGitRepository- Throws:
org.eclipse.jgit.transport.resolver.ServiceNotEnabledExceptionorg.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException- See Also:
-
UploadPackFactory.create(Object, Repository)
-
createReceivePack
public org.eclipse.jgit.transport.ReceivePack createReceivePack(jakarta.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db) throws org.eclipse.jgit.transport.resolver.ServiceNotEnabledException, org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException Requires the admin access to be able to push- Overrides:
createReceivePackin classHttpGitRepository- Throws:
org.eclipse.jgit.transport.resolver.ServiceNotEnabledExceptionorg.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException- See Also:
-
ReceivePackFactory.create(Object, Repository)
-
createReceivePack
public org.eclipse.jgit.transport.ReceivePack createReceivePack(org.eclipse.jgit.lib.Repository db) -
updateWorkspace
protected void updateWorkspace(org.eclipse.jgit.lib.Repository repo) throws IOException, org.eclipse.jgit.api.errors.GitAPIException Called when new ref is pushed to update the local workspace. The default implementation does "git reset --hard main"- Throws:
IOExceptionorg.eclipse.jgit.api.errors.GitAPIException
-
checkPushPermission
protected abstract void checkPushPermission()Do something likeJenkins.getInstance().checkPermission(Jenkins.ADMINISTER)to make sure the user has the permission to push.
-