jenkins - Jenkins:根据执行shell脚本条件发送邮件
问题描述
我在詹金斯有以下脚本
if diff file1.txt file2.txt > file3.txt ; then
echo "no difference"
else
<need to send email notitication>
fi
我听说我们可以使用“Email-ext 插件”来实现这一点,我的 Jenkins 中安装了插件。谁能解释一下如何使用Email-ext插件根据脚本条件发送邮件。
解决方案
您好,您可以参考此链接了解配置电子邮件模板的详细步骤。在您的管道脚本中,您可以添加以下步骤以获取通知:
emailext body: ''
'${SCRIPT, template="groovy-html.template"}'
'', subject: "${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - Successful",
mimeType: 'text/html', to: "email list"
groovy-html.template 是默认模板,您可以在电子邮件正文和主题中使用或编写自己的内容。
推荐阅读
- javascript - Accessing Axios data (Objects)
- bash - 从 bash 中的命令输出检查 2 列的值
- mongodb - Mongo Union All 在好友表中查找某人的好友
- android - 如何保护我的移动应用程序的云数据库?
- c++ - 为什么 wxCrafter Hello World 程序不起作用?[C++, wxWidgets]
- json - 如何将json数据重塑为另一种格式
- javascript - 对对象数组进行排序并创建具有公共值的新数组
- laravel - 提交表单Laravel 6后意外注销
- python - 如何从 Python 函数返回多个变量
- php - 从 pdo 结果中获取值