简体   繁体   English

如何在 Jenkins 工作电子邮件通知中将文件夹作为附件发送

[英]How send folder as attachments in Jenkins Job Email Notification

I have A Jenkins Job with Workspace C:\\hello_world\\test_output*我有一个带有工作区 C:\\hello_world\\test_output* 的 Jenkins 工作

in the test output folder, 2 things are one folder and one HTML file I want to send test output folder as a zip file as attachments on Jenkin jobs but I can't able to do it, please help在测试输出文件夹中,有两件事是一个文件夹和一个 HTML 文件我想将测试输出文件夹作为 zip 文件作为 Jenkins 作业的附件发送,但我无法做到,请帮忙

Think of it as two steps: 1) zipping the files;把它想象成两个步骤:1)压缩文件; and 2) sending the attachment. 2) 发送附件。

I've done this by installing 7zip, then running the command:我通过安装 7zip,然后运行命令来完成此操作:

"C:\Program Files\7-Zip\7z.exe" a -r C:\hellow_world\test_output.zip C:\job\test_output\* - mem=AES256

With the https://plugins.jenkins.io/email-ext plugin installed, there's a lot of flexibility, including the ability to send attachments.安装https://plugins.jenkins.io/email-ext插件后,有很大的灵活性,包括发送附件的能力。

Bear in mind that some mail hosts example GMAIL have started blocking things like executables, even when found within zip files.请记住,一些邮件主机示例 GMAIL 已经开始阻止诸如可执行文件之类的内容,即使在 zip 文件中找到也是如此。 If you've got users on such a host, you might run into trouble through no fault of your own.如果您在这样的主机上有用户,您可能会遇到麻烦而不是您自己的过错。

Apart from that, depending on the OS that Jenkins is running on, you could add a post-build Execute shell or Execute Windows Batch command step that calls the zip tool of your choice, and send an e-mail with attachments using the email-ext plugin for example除此之外,根据运行 Jenkins 的操作系统,您可以添加一个构建后的 Execute shell 或 Execute Windows Batch 命令步骤来调用您选择的 zip 工具,并使用电子邮件发送带有附件的电子邮件 -例如 ext 插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM