title: How to access to a static file in resources folder of the shared library from within a class in src directory
body: <p>I have the Jenkins shared library with the following structure: </p>
  
  <pre><code>resources
    |-&gt; config.yaml
    |-&gt; projects.yaml
  src
    |_ com
        |_ rathath
             |_ jenkins
                   |-&gt; Configuration.groovy
  </code></pre>
  
  <p>In src/com/rathath/jenkins/Configuration.groovy , I want to read YAML files in resources directory.</p>
  
  <p>I tried : </p>
  
  <pre><code>@Grab('org.yaml:snakeyaml:1.17')
  import org.yaml.snakeyaml.Yaml
  import hudson.FilePath
  // ...
  def readConfig() {
     def config = [:]
     def cwd = hudson.model.Executor.currentExecutor().getCurrentWorkspace().absolutize()
     new FilePath(cwd, 'resources').list('*.yaml').each {
       config &lt;&lt; it.read()
     }
  }       
  </code></pre>
  
  <p>Unfortunately, i got <code>hudson.model.Executor.currentExecutor()</code> is null. </p>
  
  <p>I tried another way: </p>
  
  <pre><code>@Grab('org.yaml:snakeyaml:1.17')
  import org.yaml.snakeyaml.Yaml
  import hudson.FilePath
  import groovy.transform.SourceURI
  import java.nio.file.Paths
  
  // ...
  @SourceURI
  URI source Uri
  
  def readConfig() {
     def config = [:]
     def cwd = new FilePath(Paths.get(sourceUri).getParent().getParent().getParent().getParent().getParent().getParent().toFile());
     new FilePath(cwd, 'resources').list('*.yaml').each {
       config &lt;&lt; it.read()
     }
  }  
  </code></pre>
  
  <p>I got bigger issue,.. Jenkins was not able to load the file : </p>
  
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class com.rathath.jenkins.Configuration
     at java.io.ObjectStreamClass.hasStaticInitializer(Native Method).
  .....
  ....
  </code></pre>