windows 从 Jenkins 发送电子邮件通知

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11884050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:47:25  来源:igfitidea点击:

Send email notification from Jenkins

windowsjenkins

提问by user1587599

I want to send email notification when any job gets done. Please let me know how can we propagate.

我想在任何工作完成时发送电子邮件通知。请让我知道我们如何传播。

回答by ppapapetrou

You can configure Jenkins to send email when a job finishes either by using a plugin or not.

您可以将 Jenkins 配置为在作业完成时发送电子邮件,无论是否使用插件。

Built-in

内置

First you have to configure your mail server settings by clicking on Manage Jenkins > Configure Systemand find the E-mail Notificationsection near the bottom of the page. Optionally also configure System Admin e-mail addressin the Jenkins Locationsection.

首先,您必须通过单击Manage Jenkins > Configure System并找到E-mail Notification页面底部附近的部分来配置邮件服务器设置。也可以System Admin e-mail address在该Jenkins Location部分中进行配置。

Then for each job got to its configuration and Add post-build action, select E-mail Notificationand configure as needed.

然后对每个作业进行配置Add post-build actionE-mail Notification然后根据需要选择和配置。

Plugin

插入

The issue with default jenkins email mechanism is that it has very limited customization.

默认 jenkins 电子邮件机制的问题在于它的自定义非常有限。

The alternate approach is to use the Email-Ext plugin, a powerful email notification mechanism. You can define some global triggers but you can also customize the settings for each job. Sending emails for success, failure or any other build status is supported.

另一种方法是使用Email-Ext 插件,这是一种强大的电子邮件通知机制。您可以定义一些全局触发器,但也可以自定义每个作业的设置。支持发送成功、失败或任何其他构建状态的电子邮件。

回答by kalyani chaudhari

  1. Go to : manage jenkins --> manage plugins --> 'available' tab --> select 'email extension plugin' --> click on button 'install without restart'

  2. manage jenkins --> configure system --> enter details in 'email notification'

  1. 转到:管理 jenkins --> 管理插件 --> “可用”选项卡 --> 选择“电子邮件扩展插件” --> 单击按钮“无需重启即可安装”

  2. 管理 jenkins --> 配置系统 --> 在“电子邮件通知”中输入详细信息

Fill up the details as given below and save it:

填写下面给出的详细信息并保存:

enter image description here

在此处输入图片说明

  1. In the configuration of project/job , tick on the 'email notification' ---> enter the details ---> save it ---> build the job/project
  1. 在项目/作业的配置中,勾选“电子邮件通知”---> 输入详细信息 ---> 保存 ---> 构建作业/项目

回答by Henk Langeveld

There's a Jenkins email-extplugin that adds triggers and recipients.

有一个Jenkins email-ext插件可以添加触发器和收件人。

回答by Nishith Pandey

This answer is for sending mail using python script & outlook through Jenkins.

此答案用于通过 Jenkins 使用 python 脚本和 Outlook 发送邮件。

You need to have PsExec.exe for this. This runs the applications remotely.

为此,您需要拥有 PsExec.exe。这将远程运行应用程序。

create a freestyle project & in that run following dos shell command:

创建一个自由式项目 & 在该运行中遵循 dos shell 命令:

path\to\psexec.exe -u username -p password -i 1 cmd -accepteula /c python path\to\SendMail.py

path\to\psexec.exe -u 用户名 -p 密码 -i 1 cmd -accepteula /c python path\to\SendMail.py

Username & password is for the windows user account where outlook runs. path\to\SendMail.py is the location of the python script. SendMail.py kinda looks like this:

用户名和密码用于运行 Outlook 的 Windows 用户帐户。path\to\SendMail.py 是 python 脚本的位置。SendMail.py 有点像这样:

import win32com.client as win32
outlook=win32.Dispatch('outlook.application')
mail=outlook.CreateItem(0)
mail.To='[email protected]'
mail.Subject="Test Mail"
mail.HTMLBody="Hiii, This is just a test mail."
mail.Send()

Here I'm using wind32com for executing outlook. The mail will be sent using the default account logged in outlook.

这里我使用wind32com 来执行outlook。邮件将使用登录 Outlook 的默认帐户发送。

You can trigger to build this project everytime after a job completes.

每次作业完成后,您都可以触发构建此项目。

Hope this is of any help to anyone :)

希望这对任何人都有帮助:)

回答by jchaturvedi

  1. launch Jenkins.
  2. access Manage Jenkins link from the main page.

  3. go to the end of the page and fill Email notification details : enter image description here

  4. Click on Test notification to verify it is sending an email.

  5. Please see the email sent from Jenkins. enter image description here

  1. 启动詹金斯。
  2. 从主页访问 Manage Jenkins 链接。

  3. 转到页面末尾并填写电子邮件通知详细信息: 在此处输入图片说明

  4. 单击测试通知以验证它是否正在发送电子邮件。

  5. 请参阅 Jenkins 发送的电子邮件。 在此处输入图片说明

enter image description here

在此处输入图片说明