Jenkins能夠使用插件進行構建,手動觸發時上傳patch文件,平臺自動會應用patch文件到項目,可是若是patch中有中文,則沒法處理。linux
谷歌、百度、修改構建機器編碼、tomcat編碼都不能解決問題,關鍵是不知道jenkins內部是怎麼調用的。因此逼不得已。研究了一下patch文件,在構建時先調用以下腳本,功能:shell
恢復patch以前的文件tomcat
刪除patch增長的文件(刪除的文件不用管)bash
使用linux的patch工具應用patch,則不會出現亂碼。
app
#! /bin/bash #file : reverse_patch.sh #author : peterguo@vip.qq.com #date : 2014.01.28 #note : use in jenkins's patch method, should called after jenkins's "applying a patch" action and before compile ... for file in `find . -name "*original~"` do cp $file ${file%.*} done if [ -f patch.diff ]; then file=`grep "(revision 0)" patch.diff | awk '{print $2}'` rm $file patch -p0 < patch.diff fi