title: Jenkins Read a Specific Line of a File in Jenkinsfile with Groovy
body: <p>I am trying to read a specific line of an <code>html</code> file in a Jenkins <code>stage</code> with <code>Groovy</code> and save its contents to an environment variable. The problem is, <code>File</code> and <code>readLines()</code> are not allowed.</p>
  
  <p>I am able to load a file with</p>
  
  <pre><code>env.WORKSPACE = pwd()
  def file = readFile "${env.WORKSPACE}/file.html"
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/38679858/5047630">Provided in this answer</a></p>
  
  <p>But how can I access instantly to the contents of line <code>n</code>? I am using <code>Jenkins 2.32</code> </p>