RedmineWithGit¶
- Table of contents
- RedmineWithGit
gitリポジトリをhttpまたはhttpsでアクセスできるようにして、かつ、Redmineのユーザアカウント名とパスワードで認証する方法です。
CentOS 7でapache経由のgitサーバーを構築
.gitconfigのhttp設定のsslCAInfoはちゃんとサイト指定する
を参考にさせていただきました。
これを書いたときの各種ソフトのバージョン¶
仮想マシンイメージ | centos-7-x86_64-minimal |
OS | CentOS Linux release 7.3.1611 (Core) |
Kernel | 2.6.32-042stab120.11 |
Apache(RPM) | 2.2.15-56.el6.centos.3 |
Ruby | 2.3.3 |
Redmine | 3.3-stable |
git(CentOS側) | 1.8.3.1 |
git(Windows側) | Git-2.12.2.2-64-bit.exe |
TortoiseGit | TortoiseGit-2.4.0.2-64bit.msi |
TortoiseGit日本語化 | TortoiseGit-LanguagePack-2.4.0.0-64bit-ja.msi |
Windows PC側にTortoiseGitをインストール¶
TortoiseGitはコマンドラインの版のgitに依存しているので、 https://git-for-windows.github.io/ からインストーラを拾ってきてインストールします。
- 注意点
- Adjusting your PATH environment はシステムに影響が少ない Use Git from Git Bash only で大丈夫
- Choosing HTTPS transport backend は Use the OpenSSL library にしないとオレオレ証明書の追加が難しい
- Configuring the line ending conversions は Checkout as-is, commit Unix-style line endings のほうが改行コードの問題が少ない(はず)
次に、TortoiseGitとその日本語化パックを https://tortoisegit.org/ から拾ってきてインストールします。
- 注意点
- English (GB) dictionary と English (US) dictionary はインストールせずともよい
- First Start Wizardの最初の画面が出たら、日本語化パックのインストーラ(TortoiseGit-LanguagePack-2.4.0.0-64bit-ja.msi)を起動して、完了後にRefreshするとLanguage:に出てくる
あとは、適当なディレクトリを右クリック-TortoiseGit-設定 で、Gitの「このユーザの設定を編集」で、.gitconfigにサーバのルート証明書のありかを追記します。下記は例です。
[http "https://ashidan.dip.jp:18703/git/"] sslCAInfo = d:/dl/MolelordSystemCA.crt
CentOS側 最初だけ必要なこと¶
Web上でよく見かける例はRedmineのデータベースとしてMySqlを使用していますが、ここではPostgreSQLを使う場合の設定を書いています。
sudo yum install mod_perl perl-Digest-SHA sudo yum install libdbi-dbd-pgsql sudo yum install perl-DBD-Pg sudo mkdir /var/lib/git sudo chown -R apache. /var/lib/git sudo vim /etc/httpd/conf.d/git.conf
git.conf の例
PerlLoadModule ::var::lib::redmine::extra::svn::Redmine SetEnv GIT_PROJECT_ROOT /var/lib/git SetEnv GIT_HTTP_EXPORT_ALL ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/ <LocationMatch "^/git"> PerlAuthenHandler Apache::Authn::Redmine::authen_handler AuthType Basic AuthName "Redmine Git Repository" AuthUserFile /dev/null Require valid-user # for Redmine Authentication RedmineDSN "DBI:Pg:dbname=redmine;host=localhost" RedmineDbUser "redmine" RedmineDBPass "******" ←自分の設定したパスワードに書き換える RedmineGitSmartHttp yes </LocationMatch>
git.confを保存したら、sudo systemctl reload httpd してください。
CentOS側 リポジトリ作成ごとに必要なこと¶
以下は、リポジトリの名前を sandbox.git とした例です。
cd /var/lib/git sudo -u apache git init --bare --shared sandbox.git cd sandbox.git sudo git update-server-info sudo mv hooks/post-update.sample hooks/post-update
Windows PC側で一通り操作を試す¶
- 適当なディレクトリを作る。
- 作ったディレクトリを右クリックして、Gitクローン(複製)を選ぶ。
- URLに たとえば https://ashidan.dip.jp:18703/git/sandbox.git のようなパスを書いてOKを押す。
- うまくいけば「成功」と出る。(warning: You appear to have cloned an empty repository. は、この時点ではリポジトリが空なので当然)
Windows PC側の操作は、 サルでもわかるGit入門 などを参考にしてください。
Redmine上でリポジトリを見られるようにする¶
- 対象のプロジェクトを閲覧している状態で、設定のリポジトリタブを選択する。
- +新しいリポジトリ をクリックする。
- 下図のように入力して 作成 をクリックする。識別子とリポジトリのパスはプロジェクトに応じて適当に書き換えるべし。
あとは http://qiita.com/mima_ita/items/82c5d5da30de3bc47e28 などを参考に設定を行ってください。
Count of this page : 206
Updated by mole lord about 2 years ago · 1 revisions