Azure devops 在电子邮件中发布作为附件交付给用户组的工件

Azure devops 在电子邮件中发布作为附件交付给用户组的工件,azure-devops,azure-pipelines,azure-pipelines-release-pipeline,Azure Devops,Azure Pipelines,Azure Pipelines Release Pipeline,我在VSTS中使用构建和发布。我在构建定义中使用“复制文件”选项,并将工件复制到文件夹中。我希望在发布结束时创建的工件(.exe、.dll、.zip等)必须附加在电子邮件中,并且必须发送到电子邮件地址列表中。 这是如何实现的。您可以使用task来实现它。详情如下: 在发布环境的末尾->添加发送电子邮件任务->配置所需选项 要通过发送电子邮件任务交付工件文件,可以选择添加附件选项并指定附件的绝对路径: 使用存档任务压缩文件,并使用下面给出的powershell脚本发送带有附件的电子邮件 现在使用

我在VSTS中使用构建和发布。我在构建定义中使用“复制文件”选项,并将工件复制到文件夹中。我希望在发布结束时创建的工件(.exe、.dll、.zip等)必须附加在电子邮件中,并且必须发送到电子邮件地址列表中。 这是如何实现的。

您可以使用task来实现它。详情如下:

在发布环境的末尾->添加发送电子邮件任务->配置所需选项

要通过发送电子邮件任务交付工件文件,可以选择添加附件选项并指定附件的绝对路径:


使用存档任务压缩文件,并使用下面给出的powershell脚本发送带有附件的电子邮件

现在使用Powershell任务并粘贴以下脚本。请编辑SMTP和电子邮件设置

$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
$Username = "Youremail@gmail.com"
$Password = "Pass@1"
$to = "senderemail@gmail.com"
#$cc = "ccemail@gmail.com"
# Below subject line will have todays date and Build status as Succeed or Failed
$subject = "$(get-date -format dd-mm-yy) Automation Test report $(Agent.JobStatus)"
$body = "Your email body text"
# Enter the path of existing Archieve output folder
$attachment = "$(Build.ArtifactStagingDirectory)/YourZipFolderName.zip"
$message = New-Object System.Net.Mail.MailMessage
$message.subject = $subject
$message.IsBodyHTML = $true
$message.body = $body
$message.to.add($to)
#$message.cc.add($cc)
$message.from = $username
$message.attachments.add($attachment)
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
$smtp.EnableSSL = $true
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
$smtp.send($message)
write-host "Mail Sent successfully using GMAIL"
请确保使用run选项作为“即使上一个任务失败,除非构建被取消”,如下所示


您是否尝试自行解决此问题?