Class FileBackedHttpGitRepository

java.lang.Object
org.jenkinsci.plugins.gitserver.HttpGitRepository
org.jenkinsci.plugins.gitserver.FileBackedHttpGitRepository

public abstract class FileBackedHttpGitRepository extends HttpGitRepository
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
    Modifier and Type
    Field
    Description
    final File
    Directory of the local workspace on the controller.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    Do something like Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER) to make sure the user has the permission to push.
    protected void
    createInitialRepository(org.eclipse.jgit.lib.Repository r)
    Called when there's no .git directory to create one.
    org.eclipse.jgit.transport.ReceivePack
    createReceivePack(javax.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db)
    Requires the admin access to be able to push
    org.eclipse.jgit.transport.ReceivePack
    createReceivePack(org.eclipse.jgit.lib.Repository db)
     
    org.eclipse.jgit.transport.UploadPack
    createUploadPack(javax.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.Repository
    Opens the repository this UI-bound object holds on to.
    protected void
    updateWorkspace(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, doDynamic, init

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • workspace

      public final File workspace
      Directory of the local workspace on the controller. There will be "./.git" that hosts the actual repository.
  • Constructor Details

    • FileBackedHttpGitRepository

      protected FileBackedHttpGitRepository(File workspace)
  • Method Details

    • openRepository

      public org.eclipse.jgit.lib.Repository openRepository() throws IOException
      Description copied from class: HttpGitRepository
      Opens the repository this UI-bound object holds on to.
      Specified by:
      openRepository in class HttpGitRepository
      Throws:
      IOException
    • createInitialRepository

      protected void createInitialRepository(org.eclipse.jgit.lib.Repository r) throws IOException
      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(javax.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.)
      Specified by:
      createUploadPack in class HttpGitRepository
      Throws:
      org.eclipse.jgit.transport.resolver.ServiceNotEnabledException
      org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException
      See Also:
      • UploadPackFactory.create(Object, Repository)
    • createReceivePack

      public org.eclipse.jgit.transport.ReceivePack createReceivePack(javax.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
      Specified by:
      createReceivePack in class HttpGitRepository
      Throws:
      org.eclipse.jgit.transport.resolver.ServiceNotEnabledException
      org.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:
      IOException
      org.eclipse.jgit.api.errors.GitAPIException
    • checkPushPermission

      protected abstract void checkPushPermission()
      Do something like Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER) to make sure the user has the permission to push.