GitLabの構築と使用
GitLabの概要
- オープンソース無料
- 差別化されたバージョン管理、オフライン同期マシンの強力なブランチ管理機能
- 便利なGUIO操作インターフェースと強力な権限管理
- ほとんどの開発ツールを統合できる高度な統合
- 組み込みのHAをサポートし、高い並行性の下で高可用性を確保
Gitlabサービスの構成
- Nginx:静的Webサーバー
- GitLab-workhourse:軽量リバースプロキシサーバー
- Git-shell:Gitコマンドを処理し、承認されたキーのリストを修正するために使用されます
- logrotate:ログファイルの管理
- Postgresql:データベース
- Redis:キャッシュサーバー
Gitlabワークフロー
- プロジェクトを作成して複製する
- プロジェクトの機能ブランチを作成する
- コードを作成してこのブランチに送信する
- プロジェクトブランチをリモートGitlabサーバーにプッシュする
- コードレビューを実施し、Master Master Branch Mergerアプリケーションを送信する
- プロジェクトリーダーはコードをレビューし、合併申請を確認します
GitLabのインストールと構成
- Centos7仮想マシンを作成する
-
事前設定のためにサーバーにログインします
- シャットダウン
firewalld
と自動起動 - Selinuxを無効にしてマシンを再起動します
- シャットダウン
- Omnibus Gitlab-ceパッケージをインストールする
[root@centos7-node4 ~]# yum -y install curl policycoreutils openssh-server openssh-client postfix vim curl-devel
[root@centos7-node4 ~]# curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
[gitlab@centos7-node4 gitlab]# sudo systemctl start postfix && sudo systemctl enable postfix
[root@centos7-node4 ~]# yum -y install gitlab-ce
- 証明書の発行
[root@centos7-node4 ~]# openssl genrsa -out "/etc/gitlab/ssl/gitlab.yeecall.cn.key" 2048
[root@centos7-node4 ~]# openssl req -new -key "/etc/gitlab/ssl/gitlab.yeecall.cn.key" -out "/etc/gitlab/ssl/gitlab.yeecall.cn.csr"
[root@centos7-node4 ~]# openssl x509 -req -days 3650 -in "/etc/gitlab/ssl/gitlab.yeecall.cn.csr" -signkey "/etc/gitlab/ssl/gitlab.yeecall.cn.key" -out "/etc/gitlab/ssl/gitlab.yeecall.cn.crt"
[root@centos7-node4 ~]# openssl dhparam -out /etc/gitlab/ssl/dhparams.pem 2048
[root@centos7-node4 ~]# chmod 600 /etc/gitlab/ssl/*
-rw------- 1 root root 424 Dec 22 22:44 /etc/gitlab/ssl/dhparams.pem
-rw------- 1 root root 1298 Dec 22 22:42 /etc/gitlab/ssl/gitlab.yeecall.cn.crt
-rw------- 1 root root 1082 Dec 22 22:40 /etc/gitlab/ssl/gitlab.yeecall.cn.csr
-rw------- 1 root root 1675 Dec 22 22:38 /etc/gitlab/ssl/gitlab.yeecall.cn.key
[root@centos7-node4 ~]# vim /etc/gitlab/gitlab.rb
external_url 'https://gitlab.yeecall.cn'
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.yeecall.cn.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.yeecall.cn.key"
nginx['ssl_dhparam'] = "/etc/gitlab/ssl/dhparams.pem"
[root@centos7-node4 ~]# gitlab-ctl reconfigure
[root@centos7-node4 ~]# vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
server_name gitlab.yeecall.cn;
rewrite ^(.*)$ https://$host$1 permanent;
[root@centos7-node4 ~]# gitlab-ctl restart
Gitlabの使用
wanghuideMBP:Desktop wanghui$ mkdir repo
wanghuideMBP:Desktop wanghui$ cd repo/
wanghuideMBP:repo wanghui$ git -c http.sslVerify=false clone https://gitlab.yeecall.cn/root/test-repo.git
wanghuideMBP:test-repo wanghui$ vim test.py
wanghuideMBP:test-repo wanghui$ git add .
wanghuideMBP:test-repo wanghui$ git commit -m "first commit"wanghuideMBP:test-repo wanghui$ git -c http.sslVerify=false push origin master
Gitlabアプリケーション
- Gitlabバックグラウンド管理
-
開発の観点からのGitlab
- コードの提出
- コードのマージ
-
運用と保守の観点からのGitlab
- アカウント管理
- 権限管理
- リソースの監視など
-
使い方を実演する
- ユーザーの作成、パスワード、および権限(開発、リード)
- コードウェアハウス管理権限を追加する
- 開発者がコードフローを提出する
[root@centos7-node3 repo]# git -c ssl.Verify=false clone https://gitlab.yeecall.cn/root/test-repo.git #使用dev克隆代码
[root@centos7-node3 repo]# cd test-repo/
[root@centos7-node3 test-repo]# git checkout -b release-1.0 #创建分支
[root@centos7-node3 test-repo]# vim test.py #更改代码
print("this is a test code")
print("this is a test code for release-1.0")
[root@centos7-node3 test-repo]# git add .
[root@centos7-node3 test-repo]# git commit -m "release-1.0"
[root@centos7-node3 test-repo]# git -c http.sslVerify=false push origin release-1.0 #同步代码
devユーザーとしてgitlabwebページにログインし、マージリクエストを送信します
マージリクエストを作成
リードユーザーがgitlabにログインしてマージリクエストを承認します。