title: Jenkins - Groovy pipeline - Using FilePath gives Could not find matching constructor
body: <p>Building on this suggestion:
  <a href="https://stackoverflow.com/questions/41250567/using-filepath-to-access-workspace-on-slave-in-jenkins-pipeline">Using FilePath to access workspace on slave in Jenkins pipeline</a>  I am trying to get the files that are dropped into the workspace by git, and iterate through those files using eachFileRecurse, by passing in the adjusted folder.  However, when calling into FilePath, I get errors.</p>
  
  <pre><code>    import groovy.io.FileType
      import java.io.File
      import java.lang.Object
      import hudson.FilePath
      import jenkins.model.Jenkins
  
      def createFilePath(path) {
      return new FilePath(Jenkins.getInstance().getComputer(env['NODE_NAME']).getChannel(), path);
      }
  
  @NonCPS // has to be NonCPS or the build breaks on the call to .each
  def getFiles(dirLoc) {
      def dir = new File (dirLoc)
      def list = []
      dir.eachFileRecurse (FileType.FILES)
              {file -&gt; if (file.name.endsWith('.txt')) {list &lt;&lt; file}}
      return list
  }
  </code></pre>
  
  <p>I get this error</p>
  
  <pre><code>groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.io.File(hudson.FilePath)
  at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1737)
  at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1537)
  </code></pre>
  
  <p>I cannot figure out what I am missing here to make this work.  Thanks in advance!</p>