如何在 Jenkins 电子邮件中包含 git changelog? [英] How to include git changelog in Jenkins emails?

查看:38
本文介绍了如何在 Jenkins 电子邮件中包含 git changelog?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将 Jenkins 生成的变更日志导入电子邮件主题(通过默认电子邮件,或 email-ext 插件)?

我是 Jenkins 配置的新手,所以如果这是一个简单的问题,我深表歉意,但我无法在 email-ext 文档中找到任何内容.

解决方案

我配置了我的 Email-ext 插件以使用 CHANGES 令牌 (此处为官方文档):

变化:${CHANGES, showPaths=true, format="%a: %r %p 
--"%m"", pathFormat="
	- %p"}

这会在我的构建通知中打印以下内容:

变化:用户名:1​​23- 项目/文件名1.m- 项目/文件名2.m--我的日志信息"

对于 HTML 消息,我在 div 中放置了相同的代码并添加了格式:

<div style="padding-left: 30px; padding-bottom: 15px;">${CHANGES, showPaths=true, format="<div><b>%a</b>: %r %p </div><div style="padding-left:30px;"> &#8212; &#8220;<em>%m</em>&#8221;</div>", pathFormat="</div><div style="padding-left:30px;">%p"}

以下是 Jenkins 发送的电子邮件中的示例屏幕截图(此特定提交来自 Subversion,但它对 Git 和其他版本控制系统的工作方式完全相同):

Is there any way to import the changelog that is generated by Jenkins to the subject of an email (either through the default email, or the email-ext plugin)?

I am new to Jenkins configuration, so I apologize if this is a simple issue, but I was not able to find anything on the email-ext documentation.

解决方案

I configured my Email-ext plug-in to use the CHANGES Token (official documentation here):

Changes:
${CHANGES, showPaths=true, format="%a: %r %p 
--"%m"", pathFormat="
	- %p"}

That prints the following in my build notifications:

Changes:
Username: 123
    - Project/Filename1.m
    - Project/Filename2.m
    -- "My log message"

For HTML messages, I placed the same code within a div and added formatting:

<div style="padding-left: 30px; padding-bottom: 15px;">
${CHANGES, showPaths=true, format="<div><b>%a</b>: %r %p </div><div style="padding-left:30px;"> &#8212; &#8220;<em>%m</em>&#8221;</div>", pathFormat="</div><div style="padding-left:30px;">%p"}
</div>

Here's a sample screenshot of how it looks in the e-mails sent out by Jenkins now (this particular commit came from Subversion, but it works exactly the same for Git and other version control systems):

这篇关于如何在 Jenkins 电子邮件中包含 git changelog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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