Day 24 : Jenkins 在Build完通知与好用套件

介绍Jenkins的章节即将进入尾声了。事实上你可能会想Jenkins默认介面这麽老气,怎麽就成为全世界最多人用的CI工具了呢? Jenkins其实强就强在他的plugin很多,今天来介绍一下有什麽厉害的Plugin可以让老老的Jenkins管家摇身一变成为现代化潮潮介面。另外我们也介绍一下Build完後可以做些什麽? 怎麽寄信给团队成员呢?

https://ithelp.ithome.com.tw/upload/images/20210926/20119044dlX6zyEWB9.png

Jenkins 寄送Email

假如我要寄Gmail,首先你要先设定Google权限给第三方。打开Google Account > 左边有一个安全性 > 拉到下面允许低安全性应用程序存取权。
https://ithelp.ithome.com.tw/upload/images/20210926/20119044delFTT4KPs.png

打开Jenkins,设定Email: 点击管理Jenkins > 设定系统 (Configuration) > 拉到下面有一个电子邮件通知(Email Notification)

  • SMTP 服务器写下smpt.gmail.com
  • 勾选 Use SMTP Authentication 并输入寄信人的Gmail帐号密码。
  • 勾选 使用SSL
  • SMTP 填写465

https://ithelp.ithome.com.tw/upload/images/20210926/20119044S0SxM3lwAX.png

测试寄信给自己,可以收到:
https://ithelp.ithome.com.tw/upload/images/20210926/201190440stoIOYW1S.png

在FreeStyle中寄信

在FreeStyle中拉到最下面有一个建置後动作 > Email通知(Email Notification) ,他会在build失败的时候寄信,现在我们故意失败一下在执行shell的时候exit 1即可。
https://ithelp.ithome.com.tw/upload/images/20210926/20119044G9YpYIIk8p.png

成功使得Build失败了,查看信箱,有寄信了:
https://ithelp.ithome.com.tw/upload/images/20210926/201190448QIIMpDaVP.png

用pipeline寄信

这里介绍一个plugin: Email Extension。在外挂程序管理下载即可,套用後就能在plugin里面使用mail功能了。
https://ithelp.ithome.com.tw/upload/images/20210926/20119044D7uI1Gn0BY.png

我们可以将email功能放在post里面,让pipeline在失败或是成功都寄信给我们。

  post {
    failure {
      emailext body: 'NO it fail',
        subject: 'Build fail QQ',
        to: '[email protected]'
    }
    success {
      emailext body: 'Yes it work',
        subject: 'Good it work',
        to: '[email protected]'
    }
  }

打开点击管理Jenkins > 设定系统 (Configuration) > 扩充电子邮件通知,和上面的设定类似:

  • SMTP 服务器写下smpt.gmail.com
  • 勾选 Use SMTP Authentication 并输入寄信人的Gmail帐号密码。
  • 勾选 使用SSL
  • SMTP 填写465
    https://ithelp.ithome.com.tw/upload/images/20210926/20119044jC7S49cP8E.png

成功寄信:
https://ithelp.ithome.com.tw/upload/images/20210926/20119044AfTOeV1oLI.png


<<:  [Day 12] 开关 Switch

>>:  Day21:Hot Flow - SharedFlow

Day 27:开始撰写 Playbook

今天努力了一个下午,终於算是勉强搞出了一组能动的 playbook,这边就来记录一下过程以及就我所知...

追求JS小姊姊系列 Day30 -- 所以姊姊追到哪了?

前情提要: 写了30天关於JavaScript文章,只有一个强烈的感觉: 真的像是在追一个人,而且是...

Day 01:入坑 Angular 的前因後果

前因 本身是个有十年以上平面设计经验的转职者,因为接触 Side Project,而开始从切版接案接...

2021-Day1. 开箱 Google Cloud Jam 活动背包

今年参赛的另一个主题,也请大家多多支持,感恩~ https://ithelp.ithome.com...

Day 12:Python基本介绍05 | 流程控制、回圈

各位安安,今天讲的是对任何程序语言都很重要也很基础的流程控制和回圈的概念,如果你先前已经学过其他程序...