jenkins - 使用 jenkins email-ext 插件更改 jenkins 工作区并通过电子邮件附加文件

标签 jenkins jenkins-plugins

我是 Jenkins 的新手,我想通过电子邮件附件添加我的测试报告。

我正在使用

Email-ext

发送电子邮件的插件。邮件发送成功,但附件未发送。

我的测试报告在eclipse项目工作空间内生成,路径是

E:\eclipse_environment\workspace\smautomation_jenkin\assets\chromeTestReport\

如何使用此插件通过电子邮件附加我的测试文件?

最佳答案

我使用的是 mac,我的解决方案适用于 mac。但我认为这个概念对于所有操作系统都是相同的。

实际上,jenkin 自动从其工作区附加文件。为此不需要任何表达。例如,在我的 mac 中,jenkins 工作区是

/users/dev/.jenkins/workspace

我在这里保存一个名为

的文件
 report.txt. 

在 email-ext 插件的“附件”中,只需编写

report.txt

不需要写任何其他东西。 jenkins 将转到其工作区并检查“report.txt”是否存在。如果存在,则将其作为附件发送。

现在有关于 Jenkins 工作区的问题。

其实jenkins有自己的工作区。您可能需要另一个工作空间。要检查 Jenkins 工作区,请像这样:

jenkins > manage jenkins > configure system.

现在在顶部你会看到

Home directory

还有一个

Advanced 

选项。点击它,你会看到

Workspace Root Directory: and its value is   
${ITEM_ROOTDIR}/workspace

ITEM_ROOTDIR 是 .jenkins 存在的位置。对我来说这是

/users/dev/.jenkins

实际上你可以在第一行看到这一点:

    Home directory  -- ur ITEM_ROOTDIR is shown in this line.

现在转到 ${ITEM_ROOTDIR}/,您将看到一个文件夹名称工作区。

现在,如果您在此工作区中保留任何文件,jenkin 会将此文件作为附件发送。显然你必须在 email-ext 插件的“附件”部分提到它。

现在,如果您想更改工作空间,请更改您的

Workspace Root Directory:  

像这样 ${ITEM_ROOTDIR}/jobs/test/workspace

这取决于你。根据你的意愿改变。

最重要的是,如果你改变你的工作空间

jenkins > manage jenkins > configure system > Advanced option under Home directory

this will be ur default workspace.

如果您只想创建一个特定的工作区

one project

你必须遵循另一个程序。

只需创建一个 Maven 作业(项目)。然后进入项目,

//click on configure, now click on "Advanced" option under "Build"
//For free style project, this is in "Advanced project option"

在那里,你会看到

Use custom workspace

选中此选项,并提供您所需的工作空间。对我来说,我是这样的:

 /users/dev/workspace/test1/

这是

the workspace only for this project.

现在您可以从这里以附件形式发送文件。

one most important thing is u must restart jenkins server

将新工作区设置为您的作业。

实际上你可以使用cp命令将文件从另一个目录复制到jenkins工作区

Execute shell option.

现在只需在 email-ext 插件的附件中提供文件名,jenkins 就会将此文件作为附件与您的电子邮件一起发送。

干杯......

关于jenkins - 使用 jenkins email-ext 插件更改 jenkins 工作区并通过电子邮件附加文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34067682/

相关文章:

jenkins - 如何将通用文件上传到 Jenkins 作业中?

jenkins - Jenkins 中的存档工件

git - 在 macOS 查看 homebrew 上安装后通过 SSH 连接到 Bitbucket repo

jenkins - 如何禁用 Jenkins 多分支管道项目

bash - 如何在 shell 脚本中使用 Jenkins 环境变量?

installation - Jenkins Pathignore 插件安装失败

Jenkins job DSL 插件 - 隐藏参数

git - 如何避免使用 jenkins 管道 check out 主节点上的源

Jenkins 和 docker : uri was not specified

jenkins - 当LDAP服务器不可用时如何登录jenkins?