|  當 Mantis 有張貼一個新的 Issue 時, 與這個 Issue 相關的 Subversion 
              更動紀錄可以自動回寫至 Mantis 這個 Issue 內的 Bug 筆記內.  
               vi /var/www/html/mantis/config_inc.php
                 
        #Source Control
        $g_source_control_account = 'svnbot';
        $g_source_control_regexp = '/\b(?:bug|issue|mantis)\s*[#]{0,1}(\d+)\b/i';
        $g_source_control_set_status_to = RESOLVED;
        $g_source_control_set_resolution_to = FIXED;
        $g_source_control_fixed_regexp = '/\bfix(?:ed|es)\s+(?:bug|issue|mantis)?\s*[#]{0,1}(\d+)\b/i';
                 
                   設定 svnbot 為這個整合的 mantis 內特殊 user 
                   只要 SubVersion 內的紀錄出現 bug 或 issue 或 mantis #編號 
                    表示整合 Mantis 內的 Issue # Bug 筆記 
                   只要 SubVersion 內的紀錄出現 fixed 或 fixes + bug 或 
                    issue 或 mantis #編號 表示整合 Mantis 內的 Issue # Bug 筆記外, 更會將 issue 
                    狀態改成已修正解決  直接執行以下的命令, 可以在 mantis 內的 Issue#2 新增 Bug 筆記
               php /var/www/html/mantis/core/checkin.php <<< "Test issue #2 by svnbot." 直接執行以下的命令, 可以在 mantis 內的 Issue#2 新增 Bug 筆記以及將問題狀態更改為以解決 php /var/www/html/mantis/core/checkin.php <<< "Test fixed issue #2 by svnbot."  如果這個步驟沒有正確在 Mantis 內出現新增的 Bug 
                筆記, 可能是這個專案並沒有給 svnbot 這個特殊使用者權限 
               vi /var/www/svn2mantis.pl
                  
                   Processing time: 
                    125ms, tokens: 221, source 
                    length: 1.2Kb  
                     
                       
                        
                           
                            #!/usr/bin/pe
                          
                           #
                           
                            # 上午 11:15 2007年6月22日
                           
                           # Jonathan Tsai
                           
                            # Ver 1.10
                           
                            #
                           
                            # 自動將 svn 訊息寫入 mantis 紀錄內
                           
                            # 
                           
                            # 參考 http://www.ichiayi.com/trywiki/tech/svnmantis 的說明方式
                           
                            # 本 script 需配合:
                           
                            #  1. /var/www/svn/xxxrepos/hooks/post-commit 一起使用
                           
                            #  2.apache user 可使用 ssh 免密碼登入 Mantis 主機 <- SVN 主機與 Mantis 主機不同時需要
                           
                           #
                           
                           # 1.00 (2007/3/26) 第一版啟用
                           
                            # 1.01 (2007/3/26) 增加 commit 後自動整合的說明
                           
                            # 1.10 (2007/6/22) 增加 遠端登入 Mantis 主機功能設定
                           
                            #
                           
                            $prgname  substr($0, rindex($0,"/")+1);
                           
                            $ver ="1.10 (2007/6/22)";
                           
                            # $sshcmd 設為空字串表示 SVN 與 Mantis 安裝在相同主機
                           
                            $sshcmd ="";
                           
                            # 否則應該輸入由 svn 主機免密碼登入 Mantis 主機的命令列
                           
                            #$sshcmd = "/usr/bin/ssh jonathan@10.10.10.96"; 
                           
                            # 讀取參數資料
                           
                            $REPOS=$ARGV[0];
                           
                            $REV=$ARGV[1];
                           
                            # 定義外部指令
                           
                            $svnlook ="export LANG=zh_TW.UTF-8;/usr/bin/svnlook";
                           
                            $phpcmd ="/usr/bin/php";
                           
                            $checkincmd ="/var/www/html/mantis/core/checkin.php";
                           
                            # 取得 svn 相關資訊
                           
                            $auth=`$svnlook author -r $REV $REPOS;
                           
                            $dt=`$svnlook date -r $REV $REPOS`;
                           
                           $changed=`$svnlook changed -r $REV $REPOS`;
                           
                            $log=`$svnlook log -r $REV $REPOS`;
                           
                            $msg="Changeset [".$REV."] by $auth\n$dt\n$log\n$changed";
                           
                            # 傳送至 mantis
                           
                            if (length($sshcmd)>0){
                           
                            `$sshcmd $phpcmd -q $checkincmd <<< "$msg"`;
                           
                           }
                           
                          else {
                           
                            `$phpcmd -q $checkincmd <<< "$msg"`;
                           
                            }
                           #!/usr/bin/perl # # 上午 11:15 2007年6月22日 # Jonathan Tsai 
                      # Ver 1.10 # # 自動將 svn 訊息寫入 mantis 紀錄內 # # 參考 http://www.ichiayi.com/trywiki/tech/svnmantis 
                      的說明方式 # 本 script 需配合: # 1. /var/www/svn/xxxrepos/hooks/post-commit 
                      一起使用 # 2.apache user 可使用 ssh 免密碼登入 Mantis 主機 <- SVN 主機與 
                      Mantis 主機不同時需要 # # 1.00 (2007/3/26) 第一版啟用 # 1.01 (2007/3/26) 
                      增加 commit 後自動整合的說明 # 1.10 (2007/6/22) 增加 遠端登入 Mantis 主機功能設定 
                      # $prgname = substr($0, rindex($0,"/")+1); $ver 
                      = "1.10 (2007/6/22)"; # $sshcmd 設為空字串表示 SVN 與 
                      Mantis 安裝在相同主機 $sshcmd = ""; # 否則應該輸入由 svn 主機免密碼登入 
                      Mantis 主機的命令列 #$sshcmd = "/usr/bin/ssh jonathan@10.10.10.96"; 
                      # 讀取參數資料 $REPOS=$ARGV[0]; $REV=$ARGV[1]; # 定義外部指令 $svnlook 
                      = "export LANG=zh_TW.UTF-8;/usr/bin/svnlook"; 
                      $phpcmd = "/usr/bin/php"; $checkincmd = "/var/www/html/mantis/core/checkin.php"; 
                      # 取得 svn 相關資訊 $auth=`$svnlook author -r $REV $REPOS`; $dt=`$svnlook 
                      date -r $REV $REPOS`; $changed=`$svnlook changed -r $REV 
                      $REPOS`; $log=`$svnlook log -r $REV $REPOS`; $msg="Changeset 
                      [".$REV."] by $auth\n$dt\n$log\n$changed"; 
                      # 傳送至 mantis if (length($sshcmd)>0) { `$sshcmd $phpcmd 
                      -q $checkincmd <<< "$msg"`; } else { 
                      `$phpcmd -q $checkincmd <<< "$msg"`; 
                      }  #!/usr/bin/perl
#
# 上午 11:15 2007年6月22日
# Jonathan Tsai
# Ver 1.10
#
# 自動將 svn 訊息寫入 mantis 紀錄內
# 
# 參考 http://www.ichiayi.com/trywiki/tech/svnmantis 的說明方式
# 本 script 需配合:
#  1. /var/www/svn/xxxrepos/hooks/post-commit 一起使用
#  2.apache user 可使用 ssh 免密碼登入 Mantis 主機 <- SVN 主機與 Mantis 主機不同時需要
#
# 1.00 (2007/3/26) 第一版啟用
# 1.01 (2007/3/26) 增加 commit 後自動整合的說明
# 1.10 (2007/6/22) 增加 遠端登入 Mantis 主機功能設定
#
$prgname = substr($0, rindex($0,"/")+1);
$ver = "1.10 (2007/6/22)";
# $sshcmd 設為空字串表示 SVN 與 Mantis 安裝在相同主機
$sshcmd = "";
# 否則應該輸入由 svn 主機免密碼登入 Mantis 主機的命令列
#$sshcmd = "/usr/bin/ssh jonathan@10.10.10.96"; 
# 讀取參數資料
$REPOS=$ARGV[0];
$REV=$ARGV[1];
# 定義外部指令
$svnlook = "export LANG=zh_TW.UTF-8;/usr/bin/svnlook";
$phpcmd = "/usr/bin/php";
$checkincmd = "/var/www/html/mantis/core/checkin.php";
# 取得 svn 相關資訊
$auth=`$svnlook author -r $REV $REPOS`;
$dt=`$svnlook date -r $REV $REPOS`;
$changed=`$svnlook changed -r $REV $REPOS`;
$log=`$svnlook log -r $REV $REPOS`;
$msg="Changeset [".$REV."] by $auth\n$dt\n$log\n$changed";
# 傳送至 mantis
if (length($sshcmd)>0) {
 `$sshcmd $phpcmd -q $checkincmd <<< "$msg"`;
}
else {
 `$phpcmd -q $checkincmd <<< "$msg"`;
}  
              
              chmod a+x /var/www/svn2mantis.pl
/var/www/svn2mantis.pl /var/www/svn/servercfg 644 Changeset [644] by jonathan
2007-03-26 11:29:55 +0800 (一, 26 3月 2007)
將 svnlook 命令前加入 LANG=zh_TW.UTF-8 來測試整合 mantis 中文訊息問題.
mantis#2
U PD-920/var/www/svn2mantis.pl  如果有多個 svn repos 就在每個 repos 內依照這步驟一一執行, 以下還是以 
              servercfg 的 svn repos 為例
               cd /var/www/svn/servercfg
cd hooks  vi post-commit
                  
                   Processing time: 
                    31ms, tokens: 27, source 
                    length: 0.07Kb  
                     
                       
                        
                           
                            #!/bin/sh
                           
                            REPOS="$1"
                           
                           REV="$2"
                           
                            /var/www/svn2mantis.pl "$REPOS""$REV"
                           
                    #!/bin/sh REPOS="$1" REV="$2" /var/www/svn2mantis.pl 
                    "$REPOS" "$REV" 
                     #!/bin/sh
REPOS="$1"
REV="$2"
/var/www/svn2mantis.pl "$REPOS" "$REV"chown apache:apache post-commit
chmod a+x post-commit 這樣一但 commit 後, 會馬上執行這個 post-commit 的 shell script, 來執行 svn2mantis.pl 
                將 SVN 內的紀錄內容整合到 Mantis 的 Issue Bug 筆記內.    
              
                 
                   SVN Server : 10.10.10.91 
                   Mantis Server : 10.10.10.96 
                   假設 svn server 是與 httpd 整合, 透過 apache 執行 
                   先設定 SVN 主機內的 jonathan 帳號可以不用密碼以相同帳號登入 Mantis 
                    主機 
                   再設定 SVN 主機內的 apache 帳號可以不用密碼以 jonathan 帳號登入 
                    Mantis 主機  
              
              su - jonathan
ssh 10.10.10.96 <- 輸入密碼確認可以登入
exit <- 回到 svn 主機
cd .ssh
ssh-keygen -d <- 產生 id_dsa.pub (詢問時均 Enter 跳下不輸入任何字元)
scp id_dsa.pub 10.10.10.96:/home/jonathan/.ssh/10.10.10.91_authorized_keys2  
              
                 
                   將 SVN 主機公鑰加入認證公鑰清單檔內 
                   將認證公鑰清單檔權限設為只有自己可以讀寫 su - jonathan
cd .ssh
cat 10.10.10.91_authorized_keys2 >> authorized_keys2
chmod 600 authorized_keys2  
              
              [jonathan@eddev ~]$ ssh jonathan@10.10.10.96
Last login: Fri Jun 22 10:14:40 2007 from 10.10.10.91
[jonathan@tryboxap04 ~]$  
              
              su -
cd /var/www
cp -a ~jonathan/.ssh .
chown -R apache:apache .ssh  
               vi /var/www/svn2mantis.pl
                  
                   Processing time: 
                    281ms, tokens: 222, source 
                    length: 1.2Kb  
                     
                       
                        
                           
                            #!/usr/bin/perl
                           
                            #
                           
                            # 上午 11:15 2007年6月22日
                           
                            # Jonathan Tsai
                           
                            # Ver 1.10
                           
                            #
                           
                            # 自動將 svn 訊息寫入 mantis 紀錄內
                           
                            # 
                           
                            # 參考 http://www.ichiayi.com/trywiki/tech/svnmantis 的說明方式
                           
                            # 本 script 需配合:
                           
                            #  1. /var/www/svn/xxxrepos/hooks/post-commit 一起使用
                           
                            #  2.apache user 可使用 ssh 免密碼登入 Mantis 主機 <- SVN 主機與 Mantis 主機不同時需要
                           
                            #
                           
                            # 1.00 (2007/3/26) 第一版啟用
                           
                            # 1.01 (2007/3/26) 增加 commit 後自動整合的說明
                           
                            # 1.10 (2007/6/22) 增加 遠端登入 Mantis 主機功能設定
                           
                            #
                           
                            $prgname = substr($0, rindex($0,"/")+1);
                           
                            $ver ="1.10 (2007/6/22)";
                           
                            # $sshcmd 設為空字串表示 SVN 與 Mantis 安裝在相同主機
                           
                            #$sshcmd = "";
                           
                            # 否則應該輸入由 svn 主機免密碼登入 Mantis 主機的命令列
                           
                            $sshcmd ="/usr/bin/ssh jonathan@10.10.10.96";
                           
                            # 讀取參數資料
                           
                         $REPOS=$ARGV[0];
                           
                            $REV=$ARGV[1];
                           
                            # 定義外部指令
                           
                           $svnlook ="export LANG=zh_TW.UTF-8;/usr/bin/svnlook";
                           
                            $phpcmd ="/usr/bin/php";
                           
                            $checkincmd ="/var/www/html/mantis/core/checkin.php";
                           
                            # 取得 svn 相關資訊
                           
                            $auth=`$svnlook author -r $REV $REPOS`;
                           
                           $dt=`$svnlook date -r $REV $REPOS`;
                           
                          $changed=`$svnlook changed -r $REV $REPOS`;
                           
                            $log=`$svnlook log -r $REV $REPOS`;
                           
                            $msg="Changeset [".$REV."] by $auth\n$dt\n$log\n$changed";
                           
                            # 傳送至 mantis
                           
                          if (length($sshcmd)>0){
                           
                            `$sshcmd $phpcmd -q $checkincmd <<< "$msg"`;
                           
                            }
                           
                            else {
                           
                            `$phpcmd -q $checkincmd <<< "$msg"`;
                           
                            }
                           #!/usr/bin/perl # # 上午 11:15 2007年6月22日 # Jonathan Tsai 
                      # Ver 1.10 # # 自動將 svn 訊息寫入 mantis 紀錄內 # # 參考 http://www.ichiayi.com/trywiki/tech/svnmantis 
                      的說明方式 # 本 script 需配合: # 1. /var/www/svn/xxxrepos/hooks/post-commit 
                      一起使用 # 2.apache user 可使用 ssh 免密碼登入 Mantis 主機 <- SVN 主機與 
                      Mantis 主機不同時需要 # # 1.00 (2007/3/26) 第一版啟用 # 1.01 (2007/3/26) 
                      增加 commit 後自動整合的說明 # 1.10 (2007/6/22) 增加 遠端登入 Mantis 主機功能設定 
                      # $prgname = substr($0, rindex($0,"/")+1); $ver 
                      = "1.10 (2007/6/22)"; # $sshcmd 設為空字串表示 SVN 與 
                      Mantis 安裝在相同主機 #$sshcmd = ""; # 否則應該輸入由 svn 主機免密碼登入 
                      Mantis 主機的命令列 $sshcmd = "/usr/bin/ssh jonathan@10.10.10.96"; 
                      # 讀取參數資料 $REPOS=$ARGV[0]; $REV=$ARGV[1]; # 定義外部指令 $svnlook 
                      = "export LANG=zh_TW.UTF-8;/usr/bin/svnlook"; 
                      $phpcmd = "/usr/bin/php"; $checkincmd = "/var/www/html/mantis/core/checkin.php"; 
                      # 取得 svn 相關資訊 $auth=`$svnlook author -r $REV $REPOS`; $dt=`$svnlook 
                      date -r $REV $REPOS`; $changed=`$svnlook changed -r $REV 
                      $REPOS`; $log=`$svnlook log -r $REV $REPOS`; $msg="Changeset 
                      [".$REV."] by $auth\n$dt\n$log\n$changed"; 
                      # 傳送至 mantis if (length($sshcmd)>0) { `$sshcmd $phpcmd 
                      -q $checkincmd <<< "$msg"`; } else { 
                      `$phpcmd -q $checkincmd <<< "$msg"`; 
                      }  #!/usr/bin/perl
#
# 上午 11:15 2007年6月22日
# Jonathan Tsai
# Ver 1.10
#
# 自動將 svn 訊息寫入 mantis 紀錄內
# 
# 參考 http://www.ichiayi.com/trywiki/tech/svnmantis 的說明方式
# 本 script 需配合:
#  1. /var/www/svn/xxxrepos/hooks/post-commit 一起使用
#  2.apache user 可使用 ssh 免密碼登入 Mantis 主機 <- SVN 主機與 Mantis 主機不同時需要
#
# 1.00 (2007/3/26) 第一版啟用
# 1.01 (2007/3/26) 增加 commit 後自動整合的說明
# 1.10 (2007/6/22) 增加 遠端登入 Mantis 主機功能設定
#
$prgname = substr($0, rindex($0,"/")+1);
$ver = "1.10 (2007/6/22)";
# $sshcmd 設為空字串表示 SVN 與 Mantis 安裝在相同主機
#$sshcmd = "";
# 否則應該輸入由 svn 主機免密碼登入 Mantis 主機的命令列
$sshcmd = "/usr/bin/ssh jonathan@10.10.10.96"; 
# 讀取參數資料
$REPOS=$ARGV[0];
$REV=$ARGV[1];
# 定義外部指令
$svnlook = "export LANG=zh_TW.UTF-8;/usr/bin/svnlook";
$phpcmd = "/usr/bin/php";
$checkincmd = "/var/www/html/mantis/core/checkin.php";
# 取得 svn 相關資訊
$auth=`$svnlook author -r $REV $REPOS`;
$dt=`$svnlook date -r $REV $REPOS`;
$changed=`$svnlook changed -r $REV $REPOS`;
$log=`$svnlook log -r $REV $REPOS`;
$msg="Changeset [".$REV."] by $auth\n$dt\n$log\n$changed";
# 傳送至 mantis
if (length($sshcmd)>0) {
 `$sshcmd $phpcmd -q $checkincmd <<< "$msg"`;
}
else {
 `$phpcmd -q $checkincmd <<< "$msg"`;
}  
              
              chmod a+x /var/www/svn2mantis.pl
/var/www/svn2mantis.pl /var/www/svn/moeaprj 1700 Changeset [1700] by chou
2007-06-20 12:09:04 +0800 (三, 20 6月 2007)
更改發文查詢的本文含附件列印 mantis#516
U EDOC2/Source/docsrv_html/inc/templates/edrecvquery_2.inc.htm  如果有多個 svn repos 就在每個 repos 內依照這步驟一一執行, 以下還是以 
              moeaprj 的 svn repos 為例 
               cd /var/www/svn/moeaprj
cd hooks  vi post-commit
                  
                   Processing time: 
                    78ms, tokens: 27, source 
                    length: 0.07Kb  
                     
                       
                        
                           
                            #!/bin/sh
                           
                            REPOS="$1"
                           
                            REV="$2"
                           
                         /var/www/svn2mantis.pl "$REPOS""$REV"
                           
                    #!/bin/sh REPOS="$1" REV="$2" /var/www/svn2mantis.pl 
                    "$REPOS" "$REV" 
                     #!/bin/sh
REPOS="$1"
REV="$2"
/var/www/svn2mantis.pl "$REPOS" "$REV"chown apache:apache post-commit
chmod a+x post-commit 這樣一但 commit 後, 會馬上執行這個 post-commit 的 shell script, 來執行 svn2mantis.pl 
                將 SVN 內的紀錄內容整合到 Mantis 的 Issue Bug 筆記內. |