title: Using Jenkins Shared Libraries as classes
body: <p>I have a Jenkins file, and i'm trying to  instantiate a groovy class from my shared library. I get "unable to resolve class Test "</p>
  
  <p>I have a src/com/org/foo.groovy file in a shared library :</p>
  
  
  
  <pre class="lang-groovy prettyprint-override"><code>package com.org
  
  class Test implements Serializable{
    String val
    Test(val) {
      this.val = val
    }
  }
  </code></pre>
  
  <p>and I'm trying to instantiate it in my jenkinsfile </p>
  
  <pre class="lang-groovy prettyprint-override"><code>@Library('Shared-Library@master') 
  import com.org //also tried to use with .foo with no success
  
  def t = new Test("a") //doesnt work
  def t = new foo.Test("a")//doesnt work
  def t = new com.org.foo.Test("a")//doesnt work
  </code></pre>
  
  <p>What does work is if I refer to the file as a class (which I don't have the access to its constructor). That is:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>@Library('Shared-Library@master')
  def t = new foo.com.org.foo()
  </code></pre>
  
  <p>This is nice, and lets me use foo functions. However, I lose the power to give the class constants and construct it with parameters.</p>
  
  <p>Any idea how I can define and use a class from shared library? 
  Thanks</p>