title: How to import/load classes into a jenkinsfile from another file
body: <p>I need to import custom classes defined outside of my jenkinsfile. These classes have constructors which require parameters. I've already tried using load() for each of the class files, but it seems this only works for script files that just define static methods. When I tried using this to load my class files, it threw an error that it could not find an <code>&lt;init&gt;</code> method.</p>
  
  <p>I currently have a way of importing these classes that works, but it requires re-cloning the repository as a library (code below). I'd like to move away from this since it's inefficient and seems like it should be unnecessary.</p>
  
  <p>current working (but not great) implementation:</p>
  
  <p>Jenkinsfile:</p>
  
  <pre><code>lib = library(identifier: "&lt;libraryName&gt;@${env.currentBranch}",
                        retriever: modernSCM([$class: 'GitSCMSource',
                        credentialsId: &lt;credentialsId&gt;,
                        id: '&lt;id&gt;',
                        remote: env.projectRemote,
                        traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait']]])).com.company.jenkins.sdk
  
  def git = lib.Git.new(this, currentStage, currentStep)
  ...
  
  </code></pre>
  
  <p>src/com/company/jenkins/sdk/Git.groovy:</p>
  
  <pre><code>package com.company.jenkins.sdk.Git
  
  class Git implements Serializable {
      def script
      def stage
      def step
  
      Git(script, stage, step){
          ...
      }
  }
  
  </code></pre>
  
  <p>I'd like to get rid of that library command and replace it with a simpler way of importing these classes.</p>