title: How to import a class from a Jenkins Shared Library into the pipeline
body: <p>I was using some global methods in the /var directory of the shared library, and everything worked fine. Now I need to keep the state of the process, so I'm writting a groovy class.
  Basically I have a class called 'ClassTest.groovy' in '/src' which is something like this;</p>
  
  
  
  <pre class="lang-groovy prettyprint-override"><code>class ClassTest {
      String testString
      def method1() { ... }
      def method2() { ... }
  }
  </code></pre>
  
  <p>and at the begining of the pipeline </p>
  
  <pre class="lang-groovy prettyprint-override"><code>library 'testlibrary@'
  import ClassTest
  </code></pre>
  
  <p>with result: </p>
  
  <blockquote>
    <p>WorkflowScript: 2: unable to resolve class ClassTest  @line 2, column 1.<br>
    import ClassTest</p>
  </blockquote>
  
  <p>before, I was just goind</p>
  
  <pre class="lang-groovy prettyprint-override"><code>library 'testlibrary@' _
  </code></pre>
  
  <p>and using the methods as</p>
  
  <pre class="lang-groovy prettyprint-override"><code>script {
      libraryTest.method1()
      ...
      libraryTest.method2()
  }
  </code></pre>
  
  <p>where the methods were in a file '/var/libraryTest.groovy' and everything worked. So I know that the shared library is there, but I'm confused with the way groovy / Jenkins handle classes / shared libraries.</p>
  
  <p>What's the correct way to import a class? I cannot find a simple example (with groovy file, file structure and pipeline) in the documentation.</p>
  
  <p>EDIT:
  I moved the file to 'src/com/company/ClassTest.groovy' and modified the pipeline as</p>
  
  <pre class="lang-groovy prettyprint-override"><code>@Library('testlibrary@') import com.company.ClassTest
  def notification = new ClassTest()
  </code></pre>
  
  <p>but now the error is</p>
  
  <blockquote>
    <p>unexpected token: package @ line 2</p>
  </blockquote>
  
  <p>the first two lines of the groovy file are:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>// src/com/company/ClassTest.groovy
  package com.company;
  </code></pre>