須要高頻率的更新oss上多個bucket的不一樣目錄的內容。shell
在svn上新建一個或者多個獨立的庫,在每一個庫編輯hooks下的post-commit文件添加命令。svn
須要安裝ossutil64 oss上傳工具,配置ossutil conf文件,svn權限密碼等工具
根據您的操做系統選擇相應的binary或者壓縮包,下載後運行相應的binary。 Linux系統(以64位系統爲例) 下載工具: wget http://gosspublic.alicdn.com/ossutil/1.6.0/ossutil64 修改文件執行權限: chmod 755 ossutil64 使用交互式配置生成配置文件: ./ossutil64 config 該命令建立將一個配置文件,在其中存儲配置信息。 請輸入配置文件路徑(默認爲:/home/user/.ossutilconfig,回車將使用默認路徑。若是用戶設置爲 其它路徑,在使用命令時須要將--config-file選項設置爲該路徑): 未輸入配置文件路徑,將使用默認配置文件:/home/user/.ossutilconfig。 對於下述配置,回車將跳過相關配置項的設置,配置項的具體含義,請使用"help config"命令查看。 請輸入endpoint:http://oss-cn-shenzhen.aliyuncs.com 請輸入accessKeyID:yourAccessKeyID 請輸入accessKeySecret:yourAccessKeySecret 請輸入stsToken: endpoint:填寫Bucket所在地域的域名信息,可參考訪問域名和數據中心。 accessKeyID:查看方式請參考建立AccessKey。 accessKeySecret:查看方式請參考建立AccessKey。 stsToken:非必配項,若採用STS臨時受權方式訪問OSS須要配置該項,不然置空便可。stsToken生成方式參考臨時訪問憑證
創建版本庫目錄 選擇一個目錄以後
mkdir -p svntestpost
*創建版本庫
svnadmin create svntest操作系統
*SVN的hookscode
#start-commit 提交前觸發事務 #pre-commit 提交完成前觸發事務 #post-commit 提交完成時觸發事務 #pre-revprop-change 版本屬性修改前觸發事務 #post-revprop-change 版本屬性修改後觸發事務
[root@hooks]# cd /data [root@hooks]# svn checkout svn://17.17.177.177/svntest test 在項目庫的 hooks/ 目錄下新建 post-commit 文件 【鉤子腳本】 [root@hooks]# cd hooks/ [root@hooks]# ls post-commit post-lock.tmpl post-unlock.tmpl pre-lock.tmpl pre-revprop-change.tmpl start-commit.tmpl post-commit.tmpl post-revprop-change.tmpl pre-commit.tmpl pre-revprop-change pre-unlock.tmpl [root@hooks]# pwd /data/svn/svntest/hooks
[root@ hooks]# cat post-commit #!/bin/sh REPOS="$1" REV="$2" mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf WEB=/data/test svn update $WEB /data/shell/oss/ossutil64 cp -r -f $WEB oss://dev/xxx/ -c /data/shell/oss/oss.config /data/shell/oss/ossutil64 cp -r -f $WEB oss://sit/xxx/ -c /data/shell/oss/oss.config /data/shell/oss/ossutil64 cp -r -f $WEB oss://uat/xxxx/ -c /data/shell/oss/oss.config