title: Using a groovy class in other jenkins groovy scripts
body: <p>I have 4 groovy scripts (2 are dsl.groovy scripts):</p>
  
  <p><strong>JobConfig.groovy</strong>:</p>
  
  <pre><code>class JobConfig {
      final name
  
      JobConfig(map) {
          name = map['name']
      }
  }
  </code></pre>
  
  <p><strong>topLevel.groovy</strong>:</p>
  
  <pre><code>import JobConfig.*
  
  def doSmthWithJobConfig(final JobConfig config) {
      println(config.name);
  }
  </code></pre>
  
  <p><strong>sublevel1.dsl.groovy</strong>:</p>
  
  <pre><code>GroovyShell shell = new GroovyShell()
  def topLevelScript = shell.parse(new File("topLevel.groovy"))
  
  def jobConfigs = [
      new JobConfig(name: 'JenkinsTestDSLs'),
      new JobConfig(name: 'JenkinsTestDSLs2')
  ]
  
  jobConfigs.each {
      topLevelScript.doSmthWithJobConfig(it);
  }
  </code></pre>
  
  <p><strong>sublevel2.dsl.groovy</strong>:</p>
  
  <pre><code>GroovyShell shell = new GroovyShell()
  def topLevelScript = shell.parse(new File("topLevel.groovy"))
  
  def jobConfigs = [
      new JobConfig(name: 'JenkinsTestDSLs3'),
      new JobConfig(name: 'JenkinsTestDSLs4')
  ]
  
  jobConfigs.each {
      topLevelScript.doSmthWithJobConfig(it);
  }
  </code></pre>
  
  <p>Now if locally I do:  </p>
  
  <pre><code>groovyc JobConfig.groovy
  </code></pre>
  
  <p>,I get no issues with running the scripts locally.</p>
  
  <p><strong>But on jenkins even if I provide the JobConfig.class at the same place where these scripts are, I can't get it running. I read <a href="https://stackoverflow.com/a/8112508/521754">here</a> that I don't need to do any compiling as long as JobConfig.groovy is on the CLASSPATH. How do I do that with jenkins? Or is there another solution?</strong></p>