2011-10-14 45 views
31

有沒有辦法將由Jenkins生成的更改日誌導入到電子郵件主題(通過默認電子郵件或email-ext plugin)?如何在Jenkins電子郵件中包含git changelog?

我是Jenkins新配置的配置,所以我很抱歉如果這是一個簡單的問題,但我無法在email-ext文檔中找到任何東西。

+0

ü沒有得到任何解決方案? –

回答

54

我配置我的電子郵件-EXT插件使用的變化令牌(​​):

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

,打印在我的生成通知如下:

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

對於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> 

這裏是一個採樣它的外觀在現在詹金斯發出的電子郵件,文件截圖(這個特別的提交來自顛覆,但它的工作原理完全爲Git和其他版本控制系統相同):

Change list for Jenkins

+2

你是怎麼知道這樣做的?我查看了官方文檔頁面,但沒有看到:1)可用令牌的列表以及如何使用它們,2)將它們放在何處(Jenkins的「配置系統」頁面中的「Default Content」)? )。 – dfrankow

+0

看起來像https://github.com/hudson-plugins/email-ext-plugin/tree/master/src/main/java/hudson/plugins/emailext/plugins/content中的每個Java類都是一個令牌。 – dfrankow

+0

另外,點擊?在「默認內容」下面的「上下文令牌參考」右側給出了描述。 – dfrankow

14

從原來的文檔: 要查看所有可用電子郵件標記及其顯示內容的列表,可以單擊「?」 (問號)與項目配置屏幕上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" 
0

不能在電子郵件的主題雖然你可以在Jenkins工作使用Git Changelog Plugin作爲後生成作用的郵件發送更改日誌給收件人作爲附件。選擇Create a file複選框,命名一個文件(CHANGELOG.md對我來說),如下圖:

enter image description here

確保您已在詹金斯JOB配置源代碼管理GIT

然後創建Editable Email Notification後生成作用,並複製git的更改日誌文件的Attachments值的名稱,如下圖:

enter image description here

相關問題