Kumar Vaibhav
Kumar Vaibhav

Reputation: 2652

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?

Upvotes: 12

Views: 38751

Answers (5)

daniel chempola
daniel chempola

Reputation: 1

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.

Upvotes: 0

Kumar Vaibhav
Kumar Vaibhav

Reputation: 2652

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:

  1. Move the "Report Directory" somewhere in "workspace". I did not prefer this because I did not want to mess up the workspace.
  2. 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 :)

Upvotes: 13

vish
vish

Reputation: 911

Jenkins will use the directory available in its workspace.

You can send multiple attachments as below.

reportFolder/html/index.html, screenShotsFolder/screenShots/*.jpg

Upvotes: 0

Lin Gong
Lin Gong

Reputation: 21

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.

Upvotes: 2

Amey
Amey

Reputation: 8548

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/*

Upvotes: 1

Related Questions