Class HttpGitRepository

java.lang.Object
org.jenkinsci.plugins.gitserver.HttpGitRepository
Direct Known Subclasses:
FileBackedHttpGitRepository

public abstract class HttpGitRepository extends Object
UI-bound object that exposes a Git repository via HTTP.

To expose a Git repository, bind this object to the URL space via stapler, for example by adding a getter to your Action object.

Author:
Kohsuke Kawaguchi
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    to make sure the user has the permission to pull.
    abstract org.eclipse.jgit.transport.ReceivePack
    createReceivePack(javax.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db)
    Returns the ReceivePack that handles "git push" from client.
    abstract org.eclipse.jgit.transport.UploadPack
    createUploadPack(javax.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db)
    Returns the UploadPack that handles "git fetch" from client.
    void
    doDynamic(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
    Handles git smart HTTP protocol.
    protected org.eclipse.jgit.http.server.GitServlet
     
    abstract org.eclipse.jgit.lib.Repository
    Opens the repository this UI-bound object holds on to.

    Methods inherited from class java.lang.Object

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

    • HttpGitRepository

      public HttpGitRepository()
  • Method Details

    • openRepository

      public abstract org.eclipse.jgit.lib.Repository openRepository() throws IOException
      Opens the repository this UI-bound object holds on to.
      Throws:
      IOException
    • createReceivePack

      public abstract 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
      Returns the ReceivePack that handles "git push" from client. The most basic implementation is the following, which allows anyone to push to this repository, so normally you want some kind of access check before that. DefaultReceivePackFactory isn't suitable here because it requires that the user has non-empty name, which isn't necessarily true in Jenkins (for example, when the security is off entirely.)
       return new ReceivePack(db);
       
      Throws:
      org.eclipse.jgit.transport.resolver.ServiceNotEnabledException
      org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException
      See Also:
      • ReceivePackFactory.create(Object, Repository)
    • createUploadPack

      public abstract 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
      Returns the UploadPack that handles "git fetch" from client. The most basic implementation is the following, which exposes this repository to everyone.
       return new DefaultUploadPackFactory().create(context,db);
       
      Throws:
      org.eclipse.jgit.transport.resolver.ServiceNotEnabledException
      org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException
      See Also:
      • UploadPackFactory.create(Object, Repository)
    • checkPullPermission

      public void checkPullPermission()
      to make sure the user has the permission to pull.
    • init

      protected org.eclipse.jgit.http.server.GitServlet init()
    • doDynamic

      public void doDynamic(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
      Handles git smart HTTP protocol.
      Throws:
      IOException
      javax.servlet.ServletException