Ant absolute path to single file in fileset

11,903

Solution 1

I solved it by changing the Jenkins Job's workspace to the directory where are the test reports and other resources located. Then I was using relative addressing to the zip file like: test-report-failed.zip

Solution 2

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>
Share:
11,903

Related videos on Youtube

papaiatis
Author by

papaiatis

Updated on June 04, 2022

Comments

  • papaiatis
    papaiatis almost 2 years

    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.

    • papaiatis
      papaiatis about 11 years
      The workspace can be different and is located in another drive. I have to use absolute paths somehow.
  • ldgorman
    ldgorman over 9 years
    this isn't helpful to anyone else