best way to evaluate a fileset?

6 views
Skip to first unread message

Ivo Bellin Salarin

unread,
Dec 23, 2014, 9:54:21 AM12/23/14
to jenkin...@googlegroups.com
Good afternoon,

I'm working on windows. I'm trying to evaluate a fileset (ant speaking).

My code looks this way, today:
    private String[] expandFileSet(AbstractBuild<?, ?> build, String pattern) {
        List<String> fileNames = new ArrayList<String>();
        try {
        for (FilePath x: build.getWorkspace().list(pattern))
            fileNames.add(x.getRemote());
        } catch (IOException ioe) {}
        catch (InterruptedException inte) {}
        return fileNames.toArray(new String[fileNames.size()]);
    }
where pattern looks like "**\*.Tests.dll"

My problem is that the list() method always returns an empty list.
Even with no parameter at all, list() returns an empty list. Even if the workspace contains a certain number of files or folders.

Previous I was using a function similar to 
   private String[] expandFileSet(AbstractBuild<?, ?> build, String pattern) {
        String[] result = new String[]{pattern};
        FileSet fileSet = new FileSet();
        org.apache.tools.ant.Project project = new org.apache.tools.ant.Project();
        fileSet.setProject(project);
        try {
            fileSet.setDir(new File(build.getWorkspace().toURI().getPath()));
            fileSet.setIncludes(pattern);
        } catch (IOException ioe) {
            return result;
        } catch (InterruptedException intE) {
            return result;
        }
        return fileSet.getDirectoryScanner(project).getIncludedFiles();
    }
(including an ant FileSet).

Well.. which is the best way to evaluate a fileset? Are there some considerations I should take into account on Windows?

Thanks in advance,
Ivo

Mark Waite

unread,
Dec 23, 2014, 9:57:23 AM12/23/14
to jenkin...@googlegroups.com
Isn't the issue with the original pattern?

I thought that even on windows you need to use a forward slash ("/") as the path separator character.  I thought the backwards slash ("\") is treated as a regular expression escape of the following character.

Mark Waite


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPc4eF9OeR_PNQpQPgcqs-_kPQZkjz1qpzVLtQqEoLP5O7sB2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks!
Mark Waite
Reply all
Reply to author
Forward
0 new messages