搭建自己的git服务器

使用的软件:
1.gitblit,https://github.com/gitblit/gitblit

下载gitblit的war包,修改web.xml的baseFolder的值,将war包放到tomcat下面。

<env-entry>
	<description>The base folder is used to specify the root location of your Gitblit data.</description>
	<env-entry-name>baseFolder</env-entry-name>
	<env-entry-type>java.lang.String</env-entry-type>
	<env-entry-value>/home/git_repo/data</env-entry-value>
</env-entry>

接下来,启动一次tomcat,gitblit就会在【/home/git_repo/data】下,创建相关文件。
接下来是对gitblit的配置进行修改。
官方建议是修改【baseFolder/gitblit.properties】,根据需要,参考【baseFolder/defaults.properties】,进行修改。

使用windows server的ldap服务

#
# GITBLIT.PROPERTIES
#
# Define your custom settings in this file and/or include settings defined in
# other properties files.
#

# Include Gitblit's 'defaults.properties' within your configuration.
#
# NOTE: Gitblit will not automatically reload "included" properties. Gitblit
# only watches the 'gitblit.properties' file for modifications.
#
# Paths may be relative to the ${baseFolder} or they may be absolute.
#
# COMMA-DELIMITED
# SINCE 1.7.0
include = defaults.properties

#
# Define your overrides or custom settings below
#
realm.authenticationProviders = ldap
realm.ldap.server = ldap://ldap的域名或ip:389
realm.ldap.username = visitor
realm.ldap.password = visitor密码
realm.ldap.maintainTeams = true
realm.ldap.accountBase = ou=xxx,dc=exsample,dc=com
realm.ldap.accountPattern = (&(objectClass=person)(sAMAccountName=${username}))
realm.ldap.groupBase = ou=xxx,dc=exsample,dc=com
#Gitblit网页上的过滤,只能查看到【Git_】开头的组(域控中存在几个git的安全组,名字为Git_App)
realm.ldap.groupMemberPattern = (&(objectClass=group)(name=Git_*)(member=${dn}))
#这个组的成员,具有admin权限
realm.ldap.admins = @Git_Admins

# 不显示ssh协议的仓库地址
web.showSshDaemonUrls = false
# 不显示git协议的仓库地址
web.showGitDaemonUrls = false
# 不显示默认的http协议的仓库地址
web.showHttpServletUrls = false
# 显示自定义的http协议的仓库地址
web.otherUrls = http://git.xxx.com/gitblit/r/{0}
# 针对otherUrls开启权限控制
web.advertiseAccessPermissionForOtherUrls = true
# 页面上不允许fork
web.allowForking = false

# 禁止删除非空的仓库
web.allowDeletingNonEmptyRepositories = false

# 开启tickets
tickets.service = com.gitblit.tickets.BranchTicketService

# 在summary页面上,显示readme的md文档
web.summaryShowReadme = true

#网页上时间的显示格式
web.timezone = Asia/Shanghai
web.timeFormat = HH:mm:ss
web.datestampShortFormat = yyyy-MM-dd
web.datestampLongFormat = EEEE, yyyy-MM-dd
web.datetimestampLongFormat = EEEE, yyyy-MM-dd HH:mm:ss Z

# 参考http://gitblit.com/faq.html,防止tomcat处于nginx后面的时候,发生/被转换的问题,有3种解决方案。
# 1.修改web.forwardSlashCharacter属性为【web.forwardSlashCharacter = !】
# 2.修改web.mountParameters属性为【web.mountParameters = false】
# 3.在tomcat的catalina.sh的开始位置,加入
# CATALINA_OPTS="${CATALINA_OPTS} -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"
#现在使用第3种方式,同时配置下面的选项
web.forwardSlashCharacter = !

使用openldap

#
# GITBLIT.PROPERTIES
#
# Define your custom settings in this file and/or include settings defined in
# other properties files.
#

# Include Gitblit's 'defaults.properties' within your configuration.
#
# NOTE: Gitblit will not automatically reload "included" properties. Gitblit
# only watches the 'gitblit.properties' file for modifications.
#
# Paths may be relative to the ${baseFolder} or they may be absolute.
#
# COMMA-DELIMITED
# SINCE 1.7.0
include = defaults.properties

#
# Define your overrides or custom settings below
#
realm.authenticationProviders = ldap
realm.ldap.server = ldap://ldap.exsample.com:389
realm.ldap.username = cn=visitor,dc=exsample,dc=com
realm.ldap.password = visitor
realm.ldap.maintainTeams = true
realm.ldap.accountBase = ou=Users,dc=exsample,dc=com
realm.ldap.accountPattern = (&(objectClass=inetOrgPerson)(uid=${username}))
realm.ldap.displayName = ${givenName}${sn}
realm.ldap.groupBase = ou=Group,dc=exsample,dc=com
#Gitblit网页上的过滤,只能查看到【scm-】开头的组(域控中存在几个git的安全组,名字为scm-App)
realm.ldap.groupMemberPattern = (&(objectClass=posixGroup)(cn=scm-*)(memberUid=${uid}))
#这个组的成员,具有admin权限
realm.ldap.admins = @scm-admin

# 不显示ssh协议的仓库地址
web.showSshDaemonUrls = false
# 不显示git协议的仓库地址
web.showGitDaemonUrls = false
# 不显示默认的http协议的仓库地址
web.showHttpServletUrls = false
# 显示自定义的http协议的仓库地址
web.otherUrls = http://git.exsample.om/git/r/{0}
# 针对otherUrls开启权限控制
web.advertiseAccessPermissionForOtherUrls = true
# 页面上不允许fork
web.allowForking = false

# 禁止删除非空的仓库
web.allowDeletingNonEmptyRepositories = false

# 开启tickets
tickets.service = com.gitblit.tickets.BranchTicketService

# 在summary页面上,显示readme的md文档
web.summaryShowReadme = true

#网页上时间的显示格式
web.timezone = Asia/Shanghai
web.timeFormat = HH:mm:ss
web.datestampShortFormat = yyyy-MM-dd
web.datestampLongFormat = EEEE, yyyy-MM-dd
web.datetimestampLongFormat = EEEE, yyyy-MM-dd HH:mm:ss Z

# 参考http://gitblit.com/faq.html,防止tomcat处于nginx后面的时候,发生/被转换的问题,有3种解决方案。
# 1.修改web.forwardSlashCharacter属性为【web.forwardSlashCharacter = !】
# 2.修改web.mountParameters属性为【web.mountParameters = false】
# 3.在tomcat的catalina.sh的开始位置,加入
# CATALINA_OPTS="${CATALINA_OPTS} -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"
#现在使用第3种方式,同时配置下面的选项
web.forwardSlashCharacter = !