I use the Jenkins Build Flow plugin to achieve parallelization. Groovy DSL performs certain file operations. Although the Restrict where this project can be run option is set to run the job on a specific slave, DSL runs on master. This is not intended.
Can someone tell me how can I restrict DSL to work on a specified slave? Even if there is a way to access the slave file system via DSL, this should work.
In general, how can we access files on a slave node from a Jenkins wizard using Groovy?
def fp = new hudson.FilePath(build.workspace.channel, "/srv/jenkins/workspace/myworkspace_on_slave_node") assert fp.exists() // returns true :) def ant = new AntBuilder() if (fp != null) { def scanner = ant.fileScanner { // fails here :(, says /srv/jenkins/workspace/myworkspace_on_slave_node not found // grab ALL files requested to be run fileset(dir: "$fp", includes: "**/*.java") } // now lets iterate over - print - and count test files int numFiles = 0 for (f in scanner) { println("Found file $f") numFiles++ } println("Total files $numFiles") }
The workspace is on a node slave, but the code above does not work when I try to open a FileSet to a remote FilePath.
source share