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版本。