Jenkins解析日志并在电子邮件中包含匹配项 [英] Jenkins parse log and include matches in Email

查看:282
本文介绍了Jenkins解析日志并在电子邮件中包含匹配项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jenkins在我的公司中设置自动化版本.每个版本都在中央标记有"id".基本上,该ID封装了与该ID相关联的所有内容,并且可以在门户中查找和跟踪所有信息.问题在于,此构建是通过Gradle标记的(因为Jenkins并不是构建软件包的唯一方法),并且Gradle日志以以下格式输出该消息:

I am using Jenkins to setup automated builds in my company. Each build is tagged centrally with an 'id'. Basically, that id encapsulates everything associated with that id, and all information can be looked up in a portal and tracked. The problem is that, this build is tagged via Gradle (since Jenkins isn't the only way one can build a package), and the Gradle log outputs this in the following format:

CENTRALBUILD.TAGGING.TAG.ID:+33295/4fr4de34
CENTRALBUILD.TAGGING.TAG.ID:+33295/2214de34

现在,我想做的是,能够获取这些标签(某些项目中有多个标签,如果它们被配置为在其他标签下构建子项目),然后将其作为电子邮件发送,例如:

Now, what I want to do is, be able to get these tags (there are mutliple tags for certain projects in case they are configured to build subprojects under a different tag) and then send it as an email like:

Hello User,
   ...

Build tags from your build:
    +33295/4fr4de34
    +33295/2214de34

我正在使用Email-ext插件,但是文档太差了,我什至不知道从哪里开始.我可以寻找的任何入门步骤或示例都很棒.

I am using the Email-ext plugin, but the documentation is so poor, that I have no idea where to even begin. Any startings steps or examples I can look for will be great.

推荐答案

首先,不知道是否读过它,但是在插件本身中提供了有关示例的相当详细的帮助.只需单击内容令牌参考 ? 链接.

Well first, don't know if you read it or not, but there is a pretty detailed help with example within the plugin itself. Just click the Content Token Reference ? link.

接下来,如果这些是在控制台日志中输出的,则可以从日志中简单地进行RegEx并按原样添加到电子邮件中.多行将按顺序拾取.

Next, if these are output in the console log, you can simple RegEx them from the log and add to email as is. Multiple lines will be picked up in order.

类似的东西:

${BUILD_LOG_REGEX, regex="(?i)\\bCENTRALBUILD\\b", showTruncatedLines=false}
注意:文档显示了\b,但是我必须使用\\b才能使其正常工作,可能是文档片段未正确转义.

${BUILD_LOG_REGEX, regex="(?i)\\bCENTRALBUILD\\b", showTruncatedLines=false}
Note: the documentation shows \b but I had to use \\b to get it to work, probably the documentation snippet is being escaped incorrectly.

与RegEx玩耍以获取所需的东西.

Play around with the RegEx to get what you need.

这篇关于Jenkins解析日志并在电子邮件中包含匹配项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆