如何检查控制台输出中的特定字符串并在Build上引发错误?

时间:2016-01-12 16:00:37

标签: jenkins compiler-errors hudson build-server

我已为Hudson配置了构建项目。

构建后的控制台输出如下:

Compiling ./main.py ...
Sorry: IndentationError: ('expected an indented block', ('./main.py', 8, 6, 'thread.start_new_thread( foo.FooThread, () )\n'))
Compiling ./udpReceiver.py ...
<<<<< build finished!
POST BUILD TASK : SUCCESS
END OF POST BUILD TASK : 0

Deleting project workspace... 
done

Finished: SUCCESS

正如您所看到的,我有一个缩进错误.... Hudson表示构建作业已成功完成。

我想要的是这样的:

检查字符串&#34; IndentationError &#34;在控制台输出文本中显示...如果是这样,那么构建应该是: 完成:失败!!!!!!!!

我该如何做到这一点?

1 个答案:

答案 0 :(得分:3)

我确认Log Parser plugin可以完成将构建状态更改为失败的工作。

安装插件并为Python构建创建规则集,例如:

enter image description here

在创建/ var / lib / jenkins / logParserRules / python-error文件中:

validate()

接下来,使用以下设置更新Python构建:

enter image description here

构建状态将更改为FAILURE:

/* @var array $data */
$allRecords = count($data);
$recordsWithErrors = 0;
foreach ($data as $result) {
    if (!$result['model']->validate()) {
        $recordsWithErrors++;
    }
}