基本設定
安裝 Email-ext plugin 後,Jenkins 專案設定會多一個 Editable Email Notification 的勾選,勾選後會多出其他選項
- Global Recipient List - 收件人,可寄給多個收件人,用逗點或是空白隔開
- Content Type - 信件內官為純文字格式或是HTML格式,預設為純文字格式
- Default Subject - 信件主旨
- Default Content - 信件內容,Jenkins 版本 2.9 之後提供了Jelly scripts 的樣板語言,讓使用者可以客製化信件的內容,現在的版本提供了三種範例:text, html, html-gamil
- Attachments - 附件,可將整個 workspace 的內容或結果打包做為附件檔寄出
Jelly Content
客製化 Jelly scripts 是非常的簡單的一件事,只要依以下步驟即可
- 建置一個 Jelly scripts,副檔名為 .jelly;你可以在 $JENKINS_HOME\.plugin\email-ext\WEB-INF\classes\hudson\plugins\emailext\templates 找到 Jelly scripts 範例
- 新增 $JENKINS_HOME\.plugin\email-templates 目錄,將 Jelly scripts 放進這個目錄
- 在 Default Content 內容填入 ${JELLY_SCRIPT, template=”html”},Jenkins 在寄信時,就會以 $JENKINS_HOME\.plugin\email-templates\html.jelly 為樣版產生信件內容
以下的圖是官網提供 txt 與 html 的畫面範例: