How to Send latest attachment using Jenkins in Email? - jenkins

I'm creating Automation xlsx file with Timestamp and in jenkins edit email attachment saying as use Ant patterns to send attachment,I've used below pattern but it is sending all xlsx files which are in that folder.
Format : **/Screenshots/*.xlsx
But i need only latest saved file.Please help me.

I don't think that's possible. Can you save the xlsx file into a second directory? Use Jenkins to clear the directory first, before the latest is created, then you can just send the contents of that directory.

You can use 'Filesystem List Parameter' Plug-in in Jenkins, which can be useful for your question. refer to link for reference-
Jenkins Plugin

Related

Can I read a txt file in jelly and embeded into an email?

I am trying to learn how to use jelly templates in Jenkins, but so far the documentation I have found is not quiet clear to me (I am quite junior) so I was wondering if is possible to read a txt file within the workspace and send it as an email in html embeded in the mail body, insted of having to attach the txt file to the email. Is there any documentation which is easy to understand for a junior? or any hints if that is possible or not at all?
Thanks

How to compress a file and copy it to another loaction via jenkins email-ext Pre-send Script?

I know little about groovy, PLZ help.
def ant = new AntBuilder()
ant.echo('hello from Ant!')
This code also not working.
Could you explain your purpose in detail? If you want to compress a file, and copy it to another location, you can use 7 Zip Command line. If you want file to be attached in your email from that plugin, you need to have the file in the project workspace.

Creating MERGED file from ditamap and then filtering it

I'm a newbie in DITA OT and I am trying to get just the merged file from my ditamap and after upply xsl to it, but I dont need any other output.
I was thinking that I could use some part of the dita-ot source code that is doing merging or to make sort of "cutted" plugin that produces just the merged xml file and proccess xsl for it, and then gives the filtered xml file.
As I understood, there is a build.xml that is making this job using dost.jar, but I cannot configure, what exactly do I need to use from it. Or is it possible to create just merged file seperately, not starting the transformation, so I can use it for my later needs?
I am very appreciate for any help.
I created a special DITA OT plugin which can be integrated in the DITA OT and used to create just the merged document:
https://github.com/oxygenxml/dita-merged/tree/master/com.oxygenxml.merged
If you choose to publish to PDF and you set the parameter clean.temp to no, after the transformation is over you should obtain in the transformation temporary files directory a file called mapFileName_MERGED.xml which has all topic references expanded.

How to attach more than two text file in email with editable email notificaton plugin in jenkins?

i have more than 2 text files generating after running a particular job in jenkins and i want to attach this two text files in email-triggered after success of the job.
Here we are using Editable email plugin, through which we can attach only one file no more that one, any please suggest.
Editable Email Notification has an Attachment section and it use Ant script.when you require an email trigger at the end of your build including files as an attachment then it will be helpful for you to know Ant script work mainly on relative addressing rather than absolute addressing. so content in attachment pattern should be some thing like this
**/foldername/*.txt
(anyextension)
Note:make sure the folder exists in your job workspace and all your text files are placed in that folder.
Or the other way if you have files in workspace , then you can use a comma separated list of file names to trigger as an attachment.
Please Use Trigger in email ext plugin and use success Trigger.
Hope this helps to some extent

Attachment using Editable Email Extension in Jenkins

I am using Editable Email plugin in Jenkins to attach a file with the email. The problem is that the plugin is unable to find the file to attach.
My file structure is like this -
ReportDirectory
workspace
ReportDirectory contains the report which I want to attach. I believe that the base directory for the plugin is the workspace. So I am giving the attachment location as
../ReportDirectory/DemoReport.html.
I have also tried
ReportDirectory/DemoReport.html
and many more options.
Am I doing something wrong?
I figured it out.
The Editable Email plugin uses the Ant File Syntax for locating the attachment. When I took at the documentation for Ant File Syntax ( http://ant.apache.org/manual/dirtasks.html ), it says that
In general, patterns are considered relative paths, relative to a task dependent base directory (the dir attribute in the case of ). Only files found below that base directory are considered. So while a pattern like ../foo.java is possible, it will not match anything when applied since the base directory's parent is never scanned for files.
Since the base directory in this case is the "workspace" and my directory "ReportDirectory" is not located in it so the Ant is not able to access it.
Two solutions exist:
Move the "Report Directory" somewhere in "workspace". I did not prefer this because I did not want to mess up the workspace.
Once the report has been created in "ReportDirectory", use your Ant\MSBuild script to copy it temporarily in the "workspace" and then the Email plugin shall be able to access it by something like **/Report.html or something.
#Amey - thanks for your efforts though :)
Another solution is create a symbolic link from $JENKINS_HOME/jobs/workspace/$workspace_name to the path with your $workspace_name. This way worked for me.
ReportDirectory/DemoReport.html
is the correct way to do it.
Please keep in mind that the path to the file and the file name is case sensitive so I assume your entering the correct name.
One more thing is to check is that the report is actually created and is located at the path mentioned by you.
Another thing you could try
ReportDirectory/*
Jenkins will use the directory available in its workspace.
You can send multiple attachments as below.
reportFolder/html/index.html, screenShotsFolder/screenShots/*.jpg
Simple answer:
Copy your file into the workspace(into your job directory), then under Attachment, just give the file name without any quotation or anything. This will automatically tell Jenkins to pick up your file. That's it!
Pls don't confuse yourself after seeing all the configurations.

Resources