Jenkins中配置邮件通知实例演示
前言:本文通过安装配置Jenkins实现邮件通知,告知一个C# Git Repo的build成功与否
一、预配条件
- 在windows上安装Jenkins和它推荐安装的Plugins
- 创建一个@163.com邮箱账号,用来发送邮件
- 准备一个测试用的git repo,此处我提供了 https://github.com/wenboyang214/jenkinsCsharpTest.git
- 运行下列脚本,Jenkins需要设置git、msbuild等的环境变量,请自行设置
二、对邮箱账号本身进行设置(此处以163邮箱为例)
Note: Jenkins中配置的邮箱secret需要授权码,而不是密码本身。因此我们需要获取授权码。




三、配置Jenkins 的系统参数

你需要做如下截图的配置
1.最好更改一下Jenkins的Workspace Root Directory,避免符号的一些错误

2.设置Jenkins的System Admin e-mail address,此处的邮箱要和你email notification的邮箱一致

3.在Extended E-mail Notification中进行如下设置,没设置的地方,保持默认

四、测试邮箱提醒功能
1.简单创建一个新的Pipeline item 名称为”test”
2.将下列脚本copy到Pipeline script中
#!/usr/bin/env groovy Jenkinsfile
pipeline {
agent any
environment {
def gitRepo="https://github.com/wenboyang214/jenkinsCsharpTest.git"
def mailRecipients="wenbya@163.com"
}
stages {
stage('1. check the git repo'){
steps{
git "${gitRepo}"
}
}
stage('3. msbuild the project'){
steps{
bat "msbuild .\\JenkinsTest\\JenkinsTest.sln"
}
}
}
post {
always {
echo 'testing email notification'
}
success {
echo 'This will run only if successful'
emailext(
body: '''${SCRIPT, template="groovy-html.template"}''',
mimeType: 'text/html',
subject: "[Jenkins]${currentBuild.fullDisplayName}",
to: "${mailRecipients}",
replyTo: "${mailRecipients}",
recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'DevelopersRecipientProvider']]
)
}
failure {
echo 'This will run only if failed'
emailext( body: '''${SCRIPT, template="groovy-html.template"}''',
mimeType: 'text/html',
subject: "[Jenkins]${currentBuild.fullDisplayName}",
to: "${mailRecipients}",
replyTo: "${mailRecipients}",
recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'DevelopersRecipientProvider']]
)
}
unstable {
echo 'This will run only if the run was marked as unstable'
}
changed {
echo 'This will run only if the state of the Pipeline has changed'
echo 'For example, if the Pipeline was previously failing but is now successful'
}
}
}
然后直接启动这个test item
五、进行对错改动,并检查邮箱是否收到邮件

更改msbuild的路径,故意让其build出错,检查是否能收到报错邮件。
bat “msbuild .\JenkinsTest\JenkinsTest.sln” => bat “msbuild .\JenkinsTest1\JenkinsTest.sln”

Jenkins中配置邮件通知实例演示的更多相关文章
- Jenkins 配置邮件通知步骤
Jenkins 配置邮件通知前言 可以在Jenkins 中配置邮件通知,比如在构建失败时发送邮件通知项目组来及时修复问题. Jenkins 邮件通知功能的插件主要包括: Mailer Plugin ( ...
- 环境部署(八):jenkins配置邮件通知
完成基于jenkins的持续集成部署后,任务构建执行完成,测试结果需要通知到相关人员.这篇博客,介绍如何在jenkins中配置邮件通知的方法... 一.安装邮件插件 由于Jenkins自带的邮件功能比 ...
- jenkins持续集成(三): jenkins配置邮件通知
完成基于jenkins的持续集成部署后,任务构建执行完成,测试结果需要通知到相关人员.这篇博客,介绍如何在jenkins中配置邮件通知的方法... 一.安装邮件插件 由于Jenkins自带的邮件功能比 ...
- Jenkins中的邮件配置
摘自http://blog.csdn.net/fullbug/article/details/53024562 Jenkins是一个很受欢迎的CI持续集成工具,能够实现项目的自动构建.打包.测试.发布 ...
- Jenkins 配置邮件通知
jenkins 是一个开源的自动化服务器.通过Jenkins,可以通过自动化加速软件开发过程.Jenkins管理和控制各种开发的生命周期过程,包括构建,文档,测试,包,阶段,部署,静态分析等等.您可以 ...
- Jenkins中Jelly邮件模板的配置
[链接]Jenkins中Jelly邮件模板的配置http://blog.csdn.net/hwhua1986/article/details/47975237
- Jenkins中配置selenium测试
Jenkins中配置selenium测试 2015/03/23 第一步在jenkins中配置selenium服务器 第二步工程配置: 第三步:执行构建: 第四步,查看报告:
- 2.在Jenkins中配置及执行 maven + selenium + testng项目
1. 在Jenkins中配置Maven与Git 1)在系统管理>管理插件>可选插件 页面分别下载Git plugin 与 Maven Integration plugin插件,安装完成后再 ...
- Ossec 安装并配置邮件通知
Ossec 安装并配置邮件通知 目录 Ossec 安装并配置邮件通知 1. 介绍 2. 软硬件环境 3. 安装步骤 3.1 Server 3.2 Agent 3.3 配置邮件通知 4. 参考资料 1. ...
随机推荐
- RetrieveFavicon 获取任何站点的 favicon
原文发表于我的技术博客 开源了一个获取任何站点 favicon 的类库,供使用. 原文发表于我的技术博客 RetrieveFavicon Project GitHub Retrieve favicon ...
- 分布式监控系统Zabbix-3.0.3-完整安装记录(3)-监控nginx,php,memcache,Low-level discovery磁盘IO
前段时间在公司IDC服务器上部署了zabbix3.0.3监控系统,除了自带的内存/带宽/CPU负载等系统资源监控模板以及mysql监控模板外,接下来对诸如nginx.php.memcache.磁盘IO ...
- Mesos+Zookeeper+Marathon的Docker管理平台部署记录(1)
随着"互联网+"时代的业务增长.变化速度及大规模计算的需求,廉价的.高可扩展的分布式x86集群已成为标准解决方案,如Google已经在几千万台服务器上部署分布式系统.Docker及 ...
- 浅谈JS的作用域链(三)
前面两篇文章介绍了JavaScript执行上下文中两个重要属性:VO/AO和scope chain.本文就来看看执行上下文中的this. 首先看看下面两个对this的概括: this是执行上下文(Ex ...
- 自己搭建的一个react脚手架
包括了: react.react router(v4), webpack(v4),echarts, google的组件库material ui, 后期会加上redux但是这些做中小型系统已经够了,de ...
- Timer定时执行
//定时器 public void timeTask(String hh,int n) {//hh="8:30:00",n=12 Timer timer = new Timer() ...
- Linux (centos7) 防火墙命令
防火墙配置 CentOS 7默认使用的是firewall作为防火墙,这里改为iptables防火墙. firewall操作: # service firewalld status; #查看防火墙状态 ...
- PAT 1038 统计同成绩学生
https://pintia.cn/problem-sets/994805260223102976/problems/994805284092887040 本题要求读入N名学生的成绩,将获得某一给定分 ...
- Linux: HowTo See Directory Tree Structure
https://www.cyberciti.biz/faq/linux-show-directory-structure-command-line/ Linux: HowTo See Director ...
- VMware 桥接 Bridge 复制物理网络连接状态
https://zhidao.baidu.com/question/535593443.html 意思就是说,VM上使用的是虚拟的网卡,也就是说VM虚拟机上的网卡不是真实存在的,而桥接还有其他的网路链 ...