title: Groovy reports that a file doesn't exists when it really is present in the system
body: <p>Whenever a build of my Jenkins job finishes, I'm sending an email with the results using the <code>Editable Email Notification</code> plugin (a.k.a. <code>Email-ext</code> plugin).
  Also, if a certain file is present in the system, I'm modifying the default content of the message to notify of the existence of that file.</p>
  
  <p>For that end, I'm using the <code>Pre-send Script</code> field of the plugin.</p>
  
  <h1>Test job configuration:</h1>
  
  <p><em><h2>Prepare an environment for the run</h2></em>
  <em><h3>Properties Content</h3></em></p>
  
  <pre><code>LOG="log.txt"
  </code></pre>
  
  <p><em><h2>Build stage</h2></em></p>
  
  <h2><em><h3>Execute shell</h3></em></h2>
  
  <pre><code>#!/bin/bash
  
  touch ${WORKSPACE}/${LOG}
  echo "this is just a log" &gt;&gt; ${WORKSPACE}/${LOG}
  </code></pre>
  
  <p><em><h2>Post-build Actions</h2></em>
  <em><h3>Editable Email Notification</h3></em>
  <em>Pre-send Script</em></p>
  
  <pre><code>File log = new File("${WORKSPACE}/${LOG}");
  logger.println(log.text);
  </code></pre>
  
  <hr>
  
  <p>When executing the build, <code>Jenkins</code> will create the file in the <code>${WORKSPACE}</code> and fill it (I'm able to print the contents from the terminal in the Jenkins slave).</p>
  
  <p>But when trying to access it from the <code>Email</code> plugin, the exception <code>java.io.FileNotFoundException</code> is raised:</p>
  
  <pre><code>java.io.FileNotFoundException: /home/jenkins/workspace/testJob/log.txt (No such file or directory)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:146)
      at groovy.util.CharsetToolkit.&lt;init&gt;(CharsetToolkit.java:69)
      at org.codehaus.groovy.runtime.DefaultGroovyMethods.newReader(DefaultGroovyMethods.java:16958)
      at org.codehaus.groovy.runtime.DefaultGroovyMethods.getText(DefaultGroovyMethods.java:16006)
      at org.codehaus.groovy.runtime.dgm$381.doMethodInvoke(Unknown Source)
      at org.codehaus.groovy.reflection.GeneratedMetaMethod$Proxy.doMethodInvoke(GeneratedMetaMethod.java:70)
      at groovy.lang.MetaClassImpl$GetBeanMethodMetaProperty.getProperty(MetaClassImpl.java:3500)
      at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:61)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
      at Script1.run(Script1.groovy:59)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)
      at hudson.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:450)
      at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:311)
      at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:297)
      at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:244)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
      at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
      at hudson.model.Build$BuildExecution.cleanUp(Build.java:195)
      at hudson.model.Run.execute(Run.java:1785)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:410)
  </code></pre>
  
  <p>I'm at a loss as why <code>Groovy</code> is complaining about the missing file, whereas if I instead print the path with</p>
  
  <pre><code>logger.println(log.getPath());
  </code></pre>
  
  <p>it will print it successfully.</p>
  
  <p><strong>NOTE:</strong>
  The <code>logger</code> variable in the <code>Pre-send Script</code> is provided by the notification plugin to access directly the build log.</p>