An open API service indexing awesome lists of open source software.

https://github.com/jenkinsci/git-server-plugin

Git Server Plugin for Jenkins
https://github.com/jenkinsci/git-server-plugin

git git-server jenkins-api-plugin jenkins-plugin

Last synced: 4 months ago
JSON representation

Git Server Plugin for Jenkins

Awesome Lists containing this project

README

          

# Git Server Plugin for Jenkins

This plugin wraps the server-side functionality of JGit so that other plugins can easily expose
Git repositories from Jenkins via its SSH transport and HTTP in a collaborative fashion.
This plugin is a library plugin, in the sense that it doesn't have any user visible feature on its own.

## Developer Guide

See [Git userContent plugin](https://plugins.jenkins.io/git-userContent) as a nice and short example of how to take advantages of this feature.

In terms of code, there are two classes that plugins like `git-userContent-plugin` should be interested in.

One is
[`HttpGitRepository`](https://github.com/jenkinsci/git-server-plugin/blob/master/src/main/java/org/jenkinsci/plugins/gitserver/HttpGitRepository.java),
which represents Git repository access via HTTP.
Typically you have some directory inside `$JENKINS_HOME` that houses the repository, then you subtype `GitHttpRepository` and override abstract methods to fill in the missing details.
[`FileBackedHttpGitRepository`](https://github.com/jenkinsci/git-server-plugin/blob/master/src/main/java/org/jenkinsci/plugins/gitserver/FileBackedHttpGitRepository.java)
is a convenient default implementation that simplifies this further.
[GitUserContentRepository](https://github.com/jenkinsci/git-userContent-plugin/blob/master/src/main/java/org/jenkinsci/plugins/gitUserContent/GitUserContentRepository.java)
in `git-userContent-plugin` is an example of using this class. This use
also implements
[RootAction](https://wiki.jenkins.io/display/JENKINS/Action+and+its+family+of+subtypes#Actionanditsfamilyofsubtypes-RootAction)
to bind this repository at `http://server/jenkins/userContent.git`, and
This combination is fairly common.

The other class of interest is [`RepositoryResolver`](https://github.com/jenkinsci/git-server-plugin/blob/master/src/main/java/org/jenkinsci/plugins/gitserver/RepositoryResolver.java).
Git server plugin adds necessary [Jenkins SSH](https://wiki.jenkins.io/display/JENKINS/Jenkins+SSH) CLI hook for exposing Git repositories over SSH.
The only missing link here is that when the client runs `git clone ssh://server/foo/bar/zot.git`,
we need to figure out what repositories on the server corresponds to `/foo/bar/zot.git`, and that's what the `RepositoryResolver` extension point does.
[The sample implementation](https://github.com/jenkinsci/git-userContent-plugin/blob/master/src/main/java/org/jenkinsci/plugins/gitUserContent/GitUserContentRepositorySSHAccess.java) in `git-userContent-plugin` will be hopefully self-explanatory.
In this case, `GitUserContentRepository` is a singleton (because it's `RootAction`), so we inject that and basically just delegate the calls to it.

## Changelog

* See [GitHub Releases](https://github.com/jenkinsci/git-server-plugin/releases/latest) for recent releases
* See the [Changelog Archive](https://github.com/jenkinsci/git-server-plugin/blob/git-server-1.9/docs/OLD_CHANGELOG.md) for versions 1.7 and older

## Reporting issues

Use [Jenkins issue tracker](https://www.jenkins.io/participate/report-issue/redirect/#17613) to report issues or feature requests
(project = `JENKINS`, component = `git-server-plugin`).