title: Jenkins groovy plugin file not found exception
body: <p>I've a script to find the all idle slaves and create a text file using Jenkins system groovy. I'm able to create a empty file and find all idle slaves where as coming to append to the file &quot;idle_slaves.list&quot; i got <strong>java.io.FileNotFoundException</strong> exception. Can somebody help me on this?</p>
  <pre><code>import jenkins.*
  import hudson.*
  import jenkins.model.Jenkins
  
  jenkins = jenkins.model.Jenkins
  
  File file1 = new File(build.workspace.toString() + &quot;/idle_slaves.list&quot;)
  
  if(build.workspace.isRemote())
  {
      channel = build.workspace.channel;
      fp = new FilePath(channel, build.workspace.toString() + &quot;/idle_slaves.list&quot;)
  } else {
      fp = new FilePath(new File(build.workspace.toString() + &quot;/idle_slaves.list&quot;))
  }
  
  if(fp != null)
  {
      fp.write(&quot;&quot;, null); //writing to file
  } 
  
  for (node in Jenkins.instance.nodes) {
    computer = node.toComputer()
    if (computer.getChannel() == null) {
      continue
    }
  if (computer.isIdle()) {
   slave = node.name.toString()
  file1.append( slave )
  }
  }
  </code></pre>
  <p>Jenkins 2.46</p>
  <p>groovy 2.0</p>
  <p><a href="https://i.stack.imgur.com/WG9Gt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WG9Gt.jpg" alt="enter image description here" /></a></p>