有没有办法将 Jenkins 生成的变更日志导入到电子邮件的主题(通过默认电子邮件,或者 电子邮件分机插件)?
我是 Jenkins 配置的新手,所以如果这是一个简单的问题,我深表歉意,但我无法在 email-ext 文档中找到任何内容。
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.
发布评论
评论(4)
我将我的 Email-ext 插件配置为使用 CHANGES 令牌(此处的官方文档 ):
在我的构建通知中打印以下内容:
对于 HTML 消息,我在 div 中放置了相同的代码并添加了格式:
这是 Jenkins 现在发出的电子邮件中的示例屏幕截图(此特定提交来自来自颠覆,但是它对于 Git 和其他版本控制系统的工作原理完全相同):
I configured my Email-ext plug-in to use the CHANGES Token (official documentation here):
That prints the following in my build notifications:
For HTML messages, I placed the same code within a div and added formatting:
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):
来自原始文档:
要查看所有可用电子邮件令牌及其显示内容的列表,您可以单击“?” (问号)与项目配置屏幕上 email-ext 部分底部的内容令牌参考相关联。
这是结果:
From original documentation:
To see a list of all available email tokens and what they display, you can click the "?" (question mark) associated with the Content Token Reference at the bottom of the email-ext section on the project configuration screen.
Here is result:
不在电子邮件主题中,但您可以使用 Git Changelog 插件 作为
Jenkins
作业中的构建后操作。选择创建文件
复选框,为文件命名(对我来说是CHANGELOG.md
),如下图所示:确保你已在 Jenkins JOB 中将源代码管理配置为GIT。
然后创建 可编辑电子邮件通知 构建后操作并复制名称git 更改日志文件的值作为
Attachments
的值,如下图所示:Not in the subject of an email though you can send the change log to the recipient as an attachment in a mail using Git Changelog Plugin as post build action in
Jenkins
Job. SelectCreate a file
checkbox, give a name to a file (CHANGELOG.md
for me), as in below image:Make sure you have configured Source Code Management as GIT in Jenkins JOB.
Then create Editable Email Notification post build action and copy the name of the git change log file as the value of
Attachments
, as in below image:从 Git Changelog Plugin 2.0 及更高版本中,您可以获取字符串形式的变更日志在管道中。然后只需在邮件中使用该变量即可。
From version 2.0 and later of Git Changelog Plugin, you can get the changelog as a string in a pipeline. And then just use that variable in the mail.