3

I am using Groovy dsl in a Jenkins script where I am passing the "include" parameter value to Ant FileSet.

def ant = new AntBuilder()
def scanner = ant.fileScanner {     
  // grab ALL files requested to be run
  fileset(dir:"/jenkins/workspace/aJob") {
        def selectedFiles = params["testSuite"]
        include(name:"$selectedFiles")
  }
}

It works if params["testSuite"] is a single expression to select file, e.g.

**/tests/*.java

It fails (appears to me that Groovy is unable to understand that value as-is) to find the files if params["testSuite"] is specified as

**/tests/test1.java, **/tests/test1.java

However, to Ant, both the above values are correct.

Can someone tell me how I can make this work?

techjourneyman
  • 1,701
  • 3
  • 33
  • 53
  • Have you tried just comma `,` or just space ` ` instead of comma space `, ` as a separator? – tim_yates Jul 06 '15 at 22:03
  • I tried with both. None worked. FileScanner finds 0 (zero) files. – techjourneyman Jul 06 '15 at 22:07
  • Does `**/tests/*.java,**/tests/*.java` work? Might be there aren't any matching files with `test1.java` (which I hope is an example, and not an actual Java source filename) – tim_yates Jul 06 '15 at 22:23
  • That does not work either. I suspect a syntax problem is likely. The file names and the FileSet paths are correct, and I verified that. – techjourneyman Jul 07 '15 at 15:29

1 Answers1

2

You're using the comma separated one in the wrong level. You're putting it in an <include> element instead of the includes attribute (see the doc page).

So to use the comma method you'd do

def ant = new AntBuilder()
def scanner = ant.fileScanner {
  // grab ALL files requested to be run
  def selectedFiles = params["testSuite"]
  fileset(dir:"/jenkins/workspace/aJob", includes: "$selectedFiles")
}

And actually, you can use comma, space, or comma space (even though the doc doesn't mention that).

Keegan
  • 11,345
  • 1
  • 25
  • 38