title: Reading file from Workspace in Jenkins with Groovy script
body: <p>I want to add a Build step with the Groovy plugin to read a file and trigger a build fail depending on the content of the file.</p>
  
  <p>How can I inject the workspace file path in the groovy plugin ?</p>
  
  <pre><code>myFileDirectory = // Get workspace filepath here ???
  myFileName = "output.log"
  myFile = new File(myFileDirectory + myFileName)
  
  lastLine = myFile.readLines().get(myFile.readLines().size().toInteger() - 1)
  if (lastLine ==~ /.Fatal Error.*/ ){
      println "Fatal error found"
      System.exit(1)
  } else{
     println "nothing to see here"
  }
  </code></pre>