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?
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).