title: How to define and use function inside Jenkins Pipeline config?
body: <p>I'm trying to create a task with a function inside:</p>
  
  <pre><code>def doCopyMibArtefactsHere(projectName) {
      step ([
          $class: 'CopyArtifact',
          projectName: $projectName,
          filter: '**/**.mib',
          fingerprintArtifacts: true, 
          flatten: true
      ]);
  }
  
  def BuildAndCopyMibsHere(projectName, params) {
      build job: $project, parameters: $params
      doCopyMibArtefactsHere($projectName)
  }
  
  
  node { 
      stage('Prepare Mib'){
          BuildAndCopyMibsHere('project1')
      }
  }
  </code></pre>
  
  <p>But this gives me an exception:</p>
  
  <blockquote>
    <p>java.lang.NoSuchMethodError: No such DSL method 'BuildAndCopyMibsHere' found among steps*</p>
  </blockquote>
  
  <p><strong>Is there any way to use embedded functions within a Pipeline script?</strong></p>