南充做网站电话,wordpress开发门户网站,外贸网站建设 google,免费微信小程序模板库文章目录 安装插件添加邮箱认证邮箱申请#xff08;以QQ邮箱网页为例#xff09;jenkins添加邮箱认证 jenkins设置邮箱相关信息配置全局邮件单个JOB邮箱配置 安装插件
点击 左侧的 Manage Jenkins — Plugins —— 左侧的 Available plugins 添加邮箱认证
邮箱申请… 文章目录 安装插件添加邮箱认证邮箱申请以QQ邮箱网页为例jenkins添加邮箱认证 jenkins设置邮箱相关信息配置全局邮件单个JOB邮箱配置 安装插件
点击 左侧的 Manage Jenkins — Plugins —— 左侧的 Available plugins 添加邮箱认证
邮箱申请以QQ邮箱网页为例
1、登入QQ邮箱 — 点击设置 — 账号 — POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务确保SMTP服务开启 2、管理服务 — 生成授权码 3、拷贝生成的授权码
有些邮箱没有显示 smtp服务 是否开启导致jenkins老是配置不对发送邮件报错。 可以使用Foxmail工具打开邮件进行配置查看服务情况 右击登入的邮箱 — 设置 — 账号 — 服务器
jenkins添加邮箱认证
1、Manage Jenkins — Credentials — 全局 2、添加邮箱认证相关信息 jenkins设置邮箱相关信息
配置邮箱有两种方式 1面向所有JOB的邮箱配置。 所有的JOB都可以使用全局邮箱中的配置进行发送邮件。存在的缺点邮箱中的配置或引用的环境变量都是一样的邮箱被多个JOB调用时会出现资源抢占的现象。能有多个接收方但是只能有固定一个发件方。 2面向单个JOB的邮箱配置。 解决第一种邮箱配置的缺点实现每个Job对应不同的发送邮件多个发送方。每个JOB都可以配置与其相关的邮件内容。
配置全局邮件
a.点击 左侧的 Manage Jenkins — System b.配置Extended E-mail Notification针对SMTP服务器、邮件内容进行配置 图中高级配置中添加上面添加的邮箱认证是否Use SSL和邮件SMTP服务配置中一样 c.邮件通知针对SMTP服务器、发件方进行配置
单个JOB邮箱配置
a.打开要配置的JOB项目 — 构建后操作 — E-mail Notification b. E-mail Notification配置 c. 编写HTMI代码实现通知邮件的默认内容。
ulli typenone b Release Notes /b /lili stylemargin-left:15px; b version /b/lili typecircle stylemargin-left:25px; CSDN /lili typecircle stylemargin-left:25px; Bazinga bingo /lili stylemargin-left:15px; b New/b/lili stylemargin-left:15px; /lili stylemargin-left:15px; b Feature list /b/lili typecircle stylemargin-left:25px; 1. A /lili typecircle stylemargin-left:25px; 2. B /lili typecircle stylemargin-left:25px; 3. C /lili typecircle stylemargin-left:25px; 4. D /lili typecircle stylemargin-left:25px; 5. E /lili typecircle stylemargin-left:25px; 6. F /lili typecircle stylemargin-left:25px; 7. G /lili typecircle stylemargin-left:25px; 8. H /lili typecircle stylemargin-left:25px; 9. I /lili typecircle stylemargin-left:25px; 10. J /lili typecircle stylemargin-left:25px; 11. K /lili stylemargin-left:15px; b Fixed Bugs /b/li
/uld. 高级配置配置编写Groovy脚本实现在每个job下动态设置临时发送人。
import jenkins.model.*
import hudson.model.*
import javax.mail.internet.InternetAddress//设置发送邮件的用户名密码 (注这里的密码时授权密码不是邮箱密码)def usernamexxxqq.com
def passwordxxxxxxxxx//写入发送邮件的用户名密码到全局配置上同时也可以设置smtp server这些选项这里由于我采用统一的邮箱服务商所以只需设置两项def descriptor1 Jenkins.instance.getDescriptorByType(hudson.plugins.emailext.ExtendedEmailPublisherDescriptor.class)
descriptor1.setSmtpAuthUsername(username)
descriptor1.setSmtpAuthPassword(password)
descriptor1.save()//写入系统管理员邮件地址到全局配置上def descriptor2 Jenkins.instance.getDescriptorByType(hudson.tasks.Mailer.DescriptorImpl.class)
descriptor2.setAdminAddress(String.format(JenkinsJobEmail %s,username))
descriptor2.save()//经过测试这个是临时设置发送人的系统管理员邮件地址不然上面设置后发送时还是不会发生改变def email new InternetAddress(String.format(JenkinsJobEmail %s, username))
msg.setFrom(email)配置完成后运行JOB看看。运行完之后自动发送是您自己编写的邮件恭喜您成功了!!!