title: Using FilePath to access workspace on slave in Jenkins pipeline
body: <p>I need to check for the existence of a certain .exe file in my workspace as part of my pipeline build job. I tried to use the below Groovy script from my Jenkinsfile to do the same. But I think the File class by default tries to look for the workspace directory on jenkins master and fails.</p>
  
  <pre><code>@com.cloudbees.groovy.cps.NonCPS
  def checkJacoco(isJacocoEnabled) {
  
      new File(pwd()).eachFileRecurse(FILES) { it -&gt;
      if (it.name == 'jacoco.exec' || it.name == 'Jacoco.exec') 
          isJacocoEnabled = true
      }
  }
  </code></pre>
  
  <p>How to access the file system on slave using Groovy from inside the Jenkinsfile? </p>
  
  <p>I also tried the below code. But I am getting <code>No such property: build for class: groovy.lang.Binding</code> error.  I also tried to use the manager object instead. But get the same error.</p>
  
  <pre><code>@com.cloudbees.groovy.cps.NonCPS
  def checkJacoco(isJacocoEnabled) {
  
      channel = build.workspace.channel 
      rootDirRemote = new FilePath(channel, pwd()) 
      println "rootDirRemote::$rootDirRemote" 
      rootDirRemote.eachFileRecurse(FILES) { it -&gt; 
          if (it.name == 'jacoco.exec' || it.name == 'Jacoco.exec') { 
              println "Jacoco Exists:: ${it.path}" 
              isJacocoEnabled = true 
      } 
  }
  </code></pre>