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
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    to make sure the user has the permission to pull.
    org.eclipse.jgit.transport.ReceivePack
    createReceivePack(jakarta.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db)
    Returns the ReceivePack that handles "git push" from client.
    org.eclipse.jgit.transport.ReceivePack
    createReceivePack(javax.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db)
    org.eclipse.jgit.transport.UploadPack
    createUploadPack(jakarta.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db)
    Returns the UploadPack that handles "git fetch" from client.
    org.eclipse.jgit.transport.UploadPack
    createUploadPack(javax.servlet.http.HttpServletRequest context, org.eclipse.jgit.lib.Repository db)
    void
    doDynamic(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 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

      protected 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 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
      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)
    • createReceivePack

      @Deprecated(since="134") 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
      Throws:
      org.eclipse.jgit.transport.resolver.ServiceNotEnabledException
      org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException
    • 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
      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)
    • createUploadPack

      @Deprecated(since="134") 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
      Throws:
      org.eclipse.jgit.transport.resolver.ServiceNotEnabledException
      org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException
    • 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.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException
      Handles git smart HTTP protocol.
      Throws:
      IOException
      jakarta.servlet.ServletException