如果值与jenkins不匹配,则需要在Jenkins日志的输出中使用shell脚本

时间:2018-05-18 06:37:25

标签: bash shell jenkins

如果值不大于控制台日志中的呈现值的输出Jenkins作业应该失败,那么任何人都可以帮助我编写shell脚本逻辑吗?

建议我使用Jenkins插件吗?

1 个答案:

答案 0 :(得分:0)

如果您想在控制台日志中使用某个值来触发构建失败,那么您可以使用此插件:

https://wiki.jenkins.io/display/JENKINS/Log+Parser+Plugin

你写正则表达式来触发信息,警告或错误。您可以将其与shell构建步骤结合起来评估参数,例如:

#!/bin/bash

echo 'Shell build step'
if [ ${yourParameter}  == "true" ]; then
    echo 'Your text to check with the log parser plugin to trigger a fail'
fi

然后将您的作业配置为使用查找文本的插件规则:

'Your text to check with the log parser plugin to trigger a fail'


该插件支持正则表达式,所以它非常强大,我已经使用了很多。