如何在Jenkins电子邮件中包含git changelog?

Igo*_*gor 41 git email hudson changelog jenkins

有没有办法将Jenkins生成的更改日志导入电子邮件主题(通过默认电子邮件或email-ext插件)?

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

Ste*_*HHH 70

我配置了我的Email-ext插件以使用CHANGES Token(官方文档):

Changes:
${CHANGES, showPaths=true, format="%a: %r %p \n--\"%m\"", pathFormat="\n\t- %p"}
Run Code Online (Sandbox Code Playgroud)

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

Changes:
Username: 123
    - Project/Filename1.m
    - Project/Filename2.m
    -- "My log message"
Run Code Online (Sandbox Code Playgroud)

对于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"}
</div>
Run Code Online (Sandbox Code Playgroud)

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

詹金斯的更改列表

  • 我怎么知道怎么做?说实话,我不知道,花了很多时间寻找例子,阅读文档,试验和逆向工程. (8认同)
  • 你怎么知道这样做的?我查看了官方文档页面,我没有看到:1)可用令牌列表以及如何使用它们,2)放置它们的位置(Jenkins的"配置系统"页面中的"默认内容"? ). (2认同)
  • 如果这个显示有多行提交消息?我试过这个.它只显示提交消息的第一行.如果提交消息为4行,则仅显示第一行.解决这个问题的任何方法? (2认同)

Yan*_*kov 17

从原始文档: 要查看所有可用电子邮件令牌及其显示内容的列表,您可以单击"?" (问号)与项目配置屏幕上email-ext部分底部的内容令牌参考相关联.

结果如下:

${CHANGES}
Displays the changes since the last build.

showDependencies
    If true, changes to projects this build depends on are shown. Defaults to false
showPaths
    If true, the paths, modifued by a commit are shown. Defaults to false
format
    For each commit listed, a string containing %X, where %x is one of:

    %a
        author
    %d
        date
    %m
        message
    %p
        path
    %r
        revision

    Not all revision systems support %d and %r. If specified showPaths argument is ignored. Defaults to "[%a] %m\\n"
pathFormat
    A string containing %p to indicate how to print paths. Defaults to "\\t%p\\n"
Run Code Online (Sandbox Code Playgroud)