title: Use multi-method global variables in Jenkins Shared Libraries
body: <p>Consider this groovy file in a repo that is loaded as shared library in Jenkins:</p>
  <pre><code>/ vars
  |
  --- Utility.groovy
  
  // Utility.groovy
  
  def funcA() { ... }
  
  def funcB() { ... }
  </code></pre>
  <p>And in the Jenkinsfile:</p>
  <pre><code>// Jenkinsfile
  
  @Library('LibName') _
  
  pipeline {
  ...
  steps {
     script {
        def util = new Utility()
        util.funcA()
     }
   }
  }
  
  </code></pre>
  <p>This works fine. But if i try to load the library dynamically:</p>
  <pre><code>// Jenkinsfile
  
  pipeline {
     ...
     steps {
         script {
            library 'LibName'
            def util = new Utility()
         }
  
      }
  
  
  }
  
  </code></pre>
  <p>That doesn't work...</p>
  <p>Can someone explain this with respect to this quote from the documentation:</p>
  <p>The documentation of Shared Libraries in Jenkins says:</p>
  <blockquote>
  <p>Internally, scripts in the vars directory are instantiated on-demand as singletons. This allows multiple methods to be defined in a single .groovy file for convenience.</p>
  </blockquote>