Class 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
      File workspace
      Directory of the local workspace on the controller.
    • Field Detail

      • workspace

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

      • FileBackedHttpGitRepository

        protected FileBackedHttpGitRepository​(File workspace)
    • Method Detail

      • 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.