Jenkins使用应用patch中文乱码问题

Jenkins能够使用插件进行构建,手动触发时上传patch文件,平台自动会应用patch文件到项目,可是若是patch中有中文,则没法处理。linux

谷歌、百度、修改构建机器编码、tomcat编码都不能解决问题,关键是不知道jenkins内部是怎么调用的。因此逼不得已。研究了一下patch文件,在构建时先调用以下脚本,功能:shell

  1. 恢复patch以前的文件tomcat

  2. 删除patch增长的文件(删除的文件不用管)bash

  3. 使用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
相关文章
相关标签/搜索