[CI Architect] gitolite3的安装与配置
版本控制管理是持续集成(CI)中一个重要的环节。时下,最流行的SCM当属GIT。在GIT服务器中,gitolite是一个小巧而易用的服务器。相比github,它并不强大,但企业内部做CI,绝对胜任。
本文介绍gitolite最新版本3.3的安装和配置。
gitolite是perl开发的git server 地址为:https://github.com/sitaramc/gitolite。
GITolite服务器信息
主机名:meridians-gitolite
IP:192.168.0.140
系统:Ubuntu 12.10
另有一台客户端,这里是hanl@hanl-ubuntu1204
1.SSH设置
1.1.[server:meridians-gitolite]安装openssh-server
sudo apt-get install openssh-server
1.2.[client:hanl-ubuntu1204]测试连接
eric@meridians-jenkins-master:~$ ssh [email protected]
The authenticity of host '192.168.0.140 (192.168.0.140)' can't be established.
ECDSA key fingerprint is e3:28:c5:b0:82:da:47:2f:34:30:bd:11:95:22:4f:4d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.140' (ECDSA) to the list of known hosts.
[email protected]'s password:
Welcome to Ubuntu 12.10 (GNU/Linux 3.5.0-17-generic x86_64)
* Documentation: https://help.ubuntu.com/
Last login: Sat Feb 2 05:43:10 2013 from 192.168.0.102
eric@meridians-gitolite:~$ exit
2.登录git server
hanl@hanl-ubuntu1204:~$ ssh [email protected]
2.1.安装GIT
sudo apt-get install git
git config --global user.name "Eric Han"
git config --global user.email "[email protected]"
(2.2.GIT代理 如果企业内部设置了代理服务器,GIT使用的端口会被封杀,需要走代理)
2.2.1.安装
sudo apt-get install socat
2.2.2.创建socat脚本
cd /home/git
sudo nano git-proxy.sh
#!/bin/bash
socat STDIO PROXY:10.11.70.71:$1:$2,proxyport=80
sudo chmod 777 git-proxy.sh
2.2.3.配置git代理
sudo nano /etc/profile
export GIT_PROXY_COMMAND=/home/git/git-proxy.sh
source /etc/profile
2.3.创建用户git
sudo adduser git
2.4.使用git身份
su git
cd ~
2.5.安装gitolite
git clone git://github.com/sitaramc/gitolite
mkdir -p ~/bin
gitolite/install -to ~/bin
nano .bashrc
PATH=/home/git/bin:$PATH
ctrl+o ctrl+x
source .bashrc
2.6.测试
gitolite help
hello, this is gitolite3 v3.3-10-g293df79 on git 1.7.9.5
2.7.退出git帐号 退出SSH登录
exit
exit
3.SSH证书
3.1.生成公私钥
hanl@hanl-ubuntu1204:~$ ssh-keygen -f ~/.ssh/han
3.2.拷贝证书到git server
sudo scp ~/.ssh/han.pub [email protected]:/tmp/han.pub
3.3.安装证书到gitolite
gitolite setup -pk /tmp/han.pub
Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/
Initialized empty Git repository in /home/git/repositories/testing.git/
WARNING: /home/git/.ssh/authorized_keys missing; creating a new one
3.4.退出SSH登录
exit
4.配置SSH无密码登录
hanl@hanl-ubuntu1204:~$ sudo nano ~/.ssh/config
# gitolite server
host gito
user git
hostname 192.168.0.140
port 22
IdentityFile ~/.ssh/han
5.克隆GITolite管理
hanl@hanl-ubuntu1204:~$ git clone gito:gitolite-admin.git
Cloning into 'gitolite-admin'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
hanl@hanl-ubuntu1204:~$ cat gitolite-admin/conf/gitolite.conf
repo gitolite-admin
RW+ = han
repo testing
RW+ = @all
6.管理GIT项目
6.1编辑
hanl@hanl-ubuntu1204:~$ nano gitolite-admin/conf/gitolite.conf
repo gitolite-admin
RW+ = han
repo testing
RW+ = @all
repo airfactory
RW+=@all
6.2.提交
hanl@hanl-ubuntu1204:~$ cd gitolite-admin/
git commit -a -m "add airfactory repo"
git push
6.3.验证
git@utfteam-virtual-machine:~$ ls repositories/
airfactory.git gitolite-admin.git testing.git
exit
6.4.检出
hanl@hanl-ubuntu1204:~$ git clone gito:airfactory
Cloning into 'airfactory'...
warning: You appear to have cloned an empty repository.
7.安装gitweb
sudo apt-get install highlight gitweb
The following extra packages will be installed:
apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common highlight-common libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap
Suggested packages:
apache2-doc apache2-suexec apache2-suexec-custom httpd-cgi libcgi-fast-perl git-doc
The following NEW packages will be installed:
apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common gitweb highlight highlight-common
libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
0 upgraded, 12 newly installed, 0 to remove and 210 not upgraded.
Need to get 2,371 kB of archives.
sudo nano /etc/apache2/apache2.conf
append:
ServerName 127.0.0.1
sudo /etc/init.d/apache2 restart
sudo nano /etc/gitweb.conf
append:
$feature{'highlight'}{'default'} = [1];
sudo usermod -a -G git www-data
sudo chmod g+r /home/git/projects.list
sudo chmod -R g+rx /home/git/repositories
sudo service apache2 restart
/etc/gitweb.conf
$projectroot = "/home/git";
chmod755 /home/git
home/git/.gitolite.rc
umask 0000
chmod -R 777 /home/git/repositories
chmod 755 /home/git/projectlist
http://192.168.0.140/gitweb/
nano gitolite-admin/conf/gitolite.conf
append:
repo gitweb
RW+ = @all
hanl@hanl-ubuntu1204:~/gitolite-admin$ git commit -a -m "add gitweb repo"
git push
更多敏捷研究,请关注:https://github.com/feuyeux/meridians