更改jenkins工作区并使用jenkins email-ext插件将文件附加到电子邮件 [英] change jenkins workspace and attach file with email using jenkins email-ext plugin

查看:145
本文介绍了更改jenkins工作区并使用jenkins email-ext插件将文件附加到电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jenkins的新手,我想在电子邮件附件中添加测试报告.

I am new to jenkins and i want to add my test report with the email attachment.

我正在使用

Email-ext

插件以发送电子邮件.电子邮件发送成功,但附件未发送.

plugin to send email. Email is sent successfully but the attached file is not sent.

我的测试报告在eclipse porject工作区中生成,路径为

My test report generates in eclipse porject workspace inside and path is

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

如何使用此插件将测试文件与电子邮件一起附加?

how i can attache my test file with email using this plug-in?

推荐答案

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

I am using mac and my solution works for mac.But i think the concept will be same for all os.

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

Actually, jenkin attach file from its workspace automatically. For this no expression is not required. For example, in my mac, jenkins workspace is

/users/dev/.jenkins/workspace

我在这里保存了一个名为

and i keep a file here named

 report.txt. 

在email-ext插件的附件"中,只需输入

And in "attachment" of email-ext plugin, just write

report.txt

无需编写任何其他内容. jenkins将转到其工作区并检查"report.txt"是否存在.如果存在,它将作为附件发送.

no need to write any other thing. jenkins will go to its workspace and check "report.txt" exist or not. if exist, it send it as attachement.

现在是关于jenkins工作区的问题.

Now question about the jenkins workspace.

实际上,詹金斯有自己的工作区.您可能需要另一个工作空间.要检查jenkins工作区,请按以下步骤操作:

Actually jenkins has its own workspace. You may need another workspace. To check jenkins workspace, go like this:

jenkins > manage jenkins > configure system.

现在您将在顶部看到

Home directory

还有一个

Advanced 

选项.点击它,你会看到

option. Click on it and u will see

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

ITEM_ROOTDIR是.jenkins所在的位置.对我来说是

ITEM_ROOTDIR is where .jenkins exist. For me this is

/users/dev/.jenkins

实际上,您可以在第一行看到它:

Actually u can see this at the first line:

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

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

now go to ${ITEM_ROOTDIR}/ and u will see a folder name workspace.

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

Now if u keep any file in this workspace, jenkin will send this file as attachement. Obviously u have to mention it in email-ext plugin "attachment" section.

现在,如果您要更改工作区,请更改

Now if u want to change ur workspace, change ur

Workspace Root Directory:  

像这样 $ {ITEM_ROOTDIR}/职位/测试/工作区

like this ${ITEM_ROOTDIR}/jobs/test/workspace

这取决于您.根据您的意愿进行更改.

it depends on you.Change according to ur wish.

最重要的是,如果您从以下位置更改您的工作

the most important thing is, if u change ur workspce from

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

this will be ur default workspace.

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

If u want to make a specific workspace for only

one project

比您必须执行另一个步骤.

than u have to follow another procedure.

只需创建一个Maven作业(项目).比进入项目

Just create a maven job (project). Than enter into the project,

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

在那里,您会看到

Use custom workspace

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

check this option, and give ur needed workspace. For me i give like this:

 /users/dev/workspace/test1/

这是

the workspace only for this project.

现在您可以从此处作为附件发送文件了.

Now u can send file from here as an attachement.

one most important thing is u must restart jenkins server

将新工作区设置为您的工作.

to set the new workspace to ur job.

实际上,您可以使用

Execute shell option.

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

Now just give the file name in attachement of email-ext plugin and jenkins will send this file as attachment with ur email.

欢呼.........

cheers.........

这篇关于更改jenkins工作区并使用jenkins email-ext插件将文件附加到电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆