Ant absolute path to single file in fileset

papaiatis picture papaiatis · Mar 7, 2013 · Viewed 11.6k times · Source

I'm using Jenkins with Email-Ext plugin to automate PHP Unit Testing. If the tests failed I want to send a notification email to myself including the zipped test reports.

The Email-Ext plugin requires an Ant Fileset definition in the attachment field. The zipped test report can be found here:

D:\Test_Reports\test-report-failed.zip

I can't find a working example of the use of fileset with absolute path to a single file.

I tried the following but didn't work:

<fileset file="D:\Test_Reports\test-report-failed.zip" />

Could find any example of using absolute paths but relative paths only.

This is the official help from the Email-ext plugin about the attachment field:

This is the set of attachments that will be used for the email. The format is a comma separated list of Ant include file syntax. The base directory is the workspace.

Answer

pepuch picture pepuch · Mar 7, 2013

You can use <include/> tag to do this. It will look like this.

<fileset dir="D:\Test_Reports">
    <include name="test-report-failed.zip" />
</fileset>

If you want to get file path in property then you can do this in that way (I've tested this and it works):

<path id="absolute.path.id">
    <fileset dir="D:\Test_Reports">
        <include name="test-report-failed.zip" />
    </fileset>
</path>
<property name="absolute.path" value="${toString:absolute.path.id}" />
<echo>file absolute path: ${absolute.path}</echo>