git+redmine連携
技術文書
2015/06/05
#redmine管理画面設定
[管理]>[設定]>[リポジトリ]
「Git」
「リポジトリ管理用のWebサービスを有効にする」
「コミットを自動取得する」
「APIキー」→自動生成
[redmineサーバー:219.94.235.108]
#ミラーリポジトリ作成
※bareではなくmirrorで作成すること
[root@localhost git]# cd /var/lib/git [root@localhost git]# git clone --mirror admin@49.212.176.26:/home/admin/git/x-generation.git
[gitサーバー:49.212.176.26]
#フック作成
[admin@www14012uf git]$ vi /home/admin/git/x-generation.git/hooks/post-receive #redmine integration WGET="/usr/bin/wget" REDMINE_URL_BASE="http://219.94.235.108:8888/" REDMINE_REPOS_API_KEY=tmi2YMbb0mtzuzvMqi0H REDMINE_PROJECT_ID=sdk echo "redmine update" RESPONSE=$($WGET "${REDMINE_URL_BASE}sys/fetch_changesets?key=${REDMINE_REPOS_API_KEY}&id=${REDMINE_PROJECT_ID}") echo $RESPONSE exit 0
#redmine管理画面確認
[SDK]>[リポジトリ]に反映されることを確認
※うまく動作しないため別の方法検討
sshの認証まわり?
http://at-aka.blogspot.jp/2013/03/redmine-git.html
ssh認証方式に変更¶
※参考URL
http://at-aka.blogspot.jp/2013/03/redmine-git.html
gitサーバーSSH公開鍵をredmineサーバーへコピー
※パスワードなしキー生成
[admin@git]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/admin/.ssh/id_rsa): Enter Enter passphrase (empty for no passphrase): Enter Enter same passphrase again: Enter Your identification has been saved in /home/admin/.ssh/id_rsa. Your public key has been saved in /home/admin/.ssh/id_rsa.pub. The key fingerprint is: 13:4a:8e:92:f3:ae:f9:45:d8:09:09:e4:51:c9:41:b1 admin@www2173ua.sakura.ne.jp The key's randomart image is: +--[ RSA 2048]----+ | .++=+ | | . ooo | | . E . . | | . B o . | | + o * S | | + . . | | . . | | o . | | ooo | +-----------------+ [admin@git]$ scp .ssh/id_rsa.pub admin@219.94.235.108:/home/admin/ [admin@redmine]$ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys [admin@redmine]$ chmod 700 ~/.ssh [admin@redmine]$ chmod 600 ~/.ssh/authorized_keys
redmineサーバーSSH公開鍵をgitサーバーへコピー
※パスワードなしキー生成
[admin@redmine]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/admin/.ssh/id_rsa): Enter Enter passphrase (empty for no passphrase): Enter Enter same passphrase again: Enter Your identification has been saved in /home/admin/.ssh/id_rsa. Your public key has been saved in /home/admin/.ssh/id_rsa.pub. The key fingerprint is: 13:4a:8e:92:f3:ae:f9:45:d8:09:09:e4:51:c9:41:b1 admin@www2173ua.sakura.ne.jp The key's randomart image is: +--[ RSA 2048]----+ | .++=+ | | . ooo | | . E . . | | . B o . | | + o * S | | + . . | | . . | | o . | | ooo | +-----------------+ [admin@redmine]$ scp .ssh/id_rsa.pub admin@49.212.176.26:/home/admin/ [admin@git]$ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys [admin@git]$ chmod 700 ~/.ssh [admin@git]$ chmod 600 ~/.ssh/authorized_keys
[admin@git]$ vi ~/git/x-generation.git/hooks/post-receive echo "redmine update" #RESPONSE=$($CURL "${REDMINE_URL_BASE}sys/fetch_changesets?key=${REDMINE_REPOS_API_KEY}&id=${REDMINE_PROJECT_ID}") #echo $RESPONSE ssh -t admin@219.94.235.108 <<EOF cd /var/lib/git/x-generation.git git fetch --all exit EOF