一、安装插件
log-parser.hpi
插件安装方式参考Jenkins的四种插件安装方式
二、设置日志解析规则
创建文档LogParsing(文件名可以自定义,但是不能带后缀),用正则表达式设置日志解析规则。
ok /not really/
# match line starting with 'error ', case-insensitive
error /(?i)^error /
error /failure/
# list of warnings here...
warning /[Ww]arning/
warning /WARNING/
# create a quick access link to lines in the report containing 'INFO'
info /INFO/
# each line containing 'BUILD' represents the start of a section for grouping errors and warnings found after the line.
# also creates a quick access link.
start /BUILD/
三、新建控制台输出解析
Manager Jenkins -> Configure System -> Console Output Parsing。
Description:解析规则命名。
Parsing Rules File:步骤二中创建日志解析规则的文件的存储路径。
四、在构建任务中应用解析规则
添加构建后操作:Console output (build log) Parsing。
使用步骤三中添加的控制台输出解析规则。
五、查看日志解析结果
我在进行其他测试的过程中更改了控制台的编码格式,正常UTF-8不会显示乱码。