title: Use withCredentials([usernamePassword( ... ) ]) in Jenkins Pipeline Library
body: <p>I'm trying to move some functions from a Jenkins Pipeline to a shared jenkins library. But I get errors when using the Credentials Binding Plugin (withCredentials)</p>
  <p>For example I have this block of code:</p>
  <pre><code>withCredentials([usernamePassword(credentialsId: 'foobar', usernameVariable: 'fooUser', passwordVariable: 'fooPassword')]) {
      // do something with credentials
  }
  </code></pre>
  <p>When I move this block to a static library function I get the following error:</p>
  <pre><code>hudson.remoting.ProxyException: 
  groovy.lang.MissingMethodException: 
  No signature of method: static mylib.MyClass.usernamePassword() is applicable for argument types: 
  (java.util.LinkedHashMap) values: [[credentialsId:foobar, usernameVariable:fooUser, ...]]
  </code></pre>
  <p>Library Code:</p>
  <pre><code>package mylib;
  
  class MyClass {
  
      def static String doSomething() {
          withCredentials([usernamePassword(credentialsId: 'foobar', usernameVariable: 'fooUser', passwordVariable: 'fooPassword')]) {
              // some code
          }
      }
  }
  </code></pre>
  <p>Usage in Jenkins Pipeline:</p>
  <pre><code>@Library('my-pipeline-library')
  import mypackage.MyClass
  ...
  MyClass.doSomething();
  </code></pre>
  <p>How can I use withCredentials/usernamePassword in my Jenkins Library? Do I need to qualify the functions with some package? Do I need extra imports? Is there any documentation about this?</p>