jenkins 可以通過subversion插件完成與svn的集成,本來這個插件的使用沒有什么難度,但是在最近的項目中卻遇到如下一些問題:
1. svn中有中文目錄,導致jenkins頁面出現亂碼或者找不到庫。
2. 使用jenkins的時候會去不存在版本庫中取文件,導致報錯。
第一個問題是由於編碼問題,首先要更改容器的字符集編碼如更改tomcat中server.xml的connector的URIEncoding='utf-8'。
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding='utf-8' />
其次應該更改瀏覽器中字符集編碼如更改chrome或者firefox中的字符集編碼格式,由於svn服務器的字符集編碼默認為utf-8,所以務必使這三者的字符集編碼保持一致。當然最佳的方案是不要在svn中建立中文目錄,一律使用英文,中文處理起來非常不方便。
關於第二個問題就更奇葩了,配置好svn后執行jenkins job構建信息始終是:
org.tmatesoft.svn.core.SVNException: svn: E195012: Unable to find repository location for 'svn://se-repo.twi1.electronics.ruag.com/repos/exconbasis/tags/Release4.1/4.1.2.8' in revision '5'842'
但是當前的版本庫根本不是‘5842’而是‘6874’,這讓人非常納悶,jenkins為什么會去這個庫取文件,排查了一整天,總算找到問題,
https://issues.jenkins-ci.org/browse/JENKINS-3342中提到
when was the branch created? I'm guessing the error message may actually be correct (that path did not exist at revision 12430), and the problem here is why is it trying that revision? can you check the clock difference between hudson server and svn server?
由於jenkins所在的服務器系統時間和svn服務器的系統時間根本不一致,導致出錯,更改完jenkins服務器時間后就解決了此問題。
現在還不能確定jenkins是否通過系統時間去計算svn服務器revision版本。