title: How to import groovy package/class into pipeline?
body: <p>I'm writing a Jenkins shared library.</p>
  
  <p>I'm not a coder myself and because of that I bump into many errors, which usually I don't know how to solve.</p>
  
  <p>My shared library structure looks like so:</p>
  
  <pre><code>itai@Itais-MBP ~/src/company/pipeline_utils -  (master) $ tree -f
  .
  ├── ./1
  ├── ./README.md
  ├── ./functions.groovy
  ├── ./src
  │   └── ./src/com
  │       ├── ./src/com/company
  │       │   ├── ./src/com/company/pipelines
  │       │   │   └── ./src/com/company/pipelines/standardPipeline.groovy
  │       │   └── ./src/com/company/utils
  │       │       ├── ./src/com/company/utils/Git.groovy
  │       │       ├── ./src/com/company/utils/SlackPostBuild.groovy
  │       │       ├── ./src/com/company/utils/dockerBuild.groovy
  │       │       ├── ./src/com/company/utils/dockerTest.groovy
  │       │       ├── ./src/com/company/utils/notifyEmail.groovy
  │       │       ├── ./src/com/company/utils/notifySlack.groovy
  │       │       ├── ./src/com/company/utils/pipeline.groovy
  │       │       └── ./src/com/company/utils/pipelineFunctions.groovy
  │       └── ./src/com/company-in-idea
  ├── ./test_utils.groovy
  ├── ./utils.groovy
  └── ./vars
      ├── ./vars/standardPipeline.groovy
      └── ./vars/utils.groovy
  </code></pre>
  
  <p>The pipeline file looks like so:</p>
  
  <pre><code>itai@Itais-MBP ~/src/company/pipeline_utils -  (master) $ cat ./vars/standardPipeline.groovy
  import com.company.utils.Git;
  
   def call(body) {
  
          def config = [:]
          body.resolveStrategy = Closure.DELEGATE_FIRST
          body.delegate = config
          body()
  
          node {
              // Clean workspace before doing anything
              deleteDir()
  
              try {
                  stage ('Clone') {
                      checkout scm
                                          def committer = getCommitter()
                  }
                  stage ('Build') {
                      sh "echo 'building ${config.projectName} ...'"
                  }
                  stage ('Tests') {
                      parallel 'static': {
                          sh "echo 'shell scripts to run static tests...'"
                      },
                      'unit': {
                          sh "echo 'shell scripts to run unit tests...'"
                      },
                      'integration': {
                          sh "echo 'shell scripts to run integration tests...'"
                      }
                  }
                  stage ('Deploy') {
                      sh "echo 'deploying to server ${config.serverDomain}...'"
                      sh "echo Itai ganot"
                      sh "echo Itai"
                  }
              } catch (err) {
                  currentBuild.result = 'FAILED'
                  throw err
              }
          }
      }
  </code></pre>
  
  <p>You can see in the pipeline file that I import "com.company.utils.Git", the git function file looks like so:</p>
  
  <pre><code>itai@Itais-MBP ~/src/company/pipeline_utils -  (master) $ cat ./src/com/company/utils/Git.groovy
  #!/usr/bin/env groovy
  package com.company.utils;
  
      def sh_out(command) {
      sh(returnStdout: true, script: command).trim()
    }
  
      def getCommitter(){
          node {
          committer = this.sh_out('git show -s --format=\'%ce\' | tr -d "\'" | cut -d@ -f1')
          return committer
          }
      }
  
      def getRepo(){
          node {
              reponame = this.sh_out('basename $(git remote show -n origin | grep Push | cut -d: -f2- | rev | cut -c5- | rev)')
              return reponame
          }
      }
  
      void gitClean(){
          node {
              this.sh_out('''
                  sudo chown -R ubuntu:ubuntu .
                  if [ -d ".git" ]; then
                      sudo git reset --hard &amp;&gt;/dev/null
                      sudo git clean -fxd &amp;&gt;/dev/null
                      sudo git tag -d $(git tag) &amp;&gt;/dev/null
                  fi
              || true ''')
          }
      }
  return this
  </code></pre>
  
  <p>The Jenkinsfile looks like so:</p>
  
  <pre><code>@Library("company") _
  standardPipeline {
      projectName = "Project1"
      serverDomain = "Project1 Server Domain"
  }
  </code></pre>
  
  <p>When I run the job, it fails with the following error:</p>
  
  <blockquote>
    <p>java.lang.NoSuchMethodError: No such DSL method 'getCommitter' found
    among steps [AddInteractivePromotion, ArtifactoryGradleBuild,
    ArtifactoryMavenBuild, ConanAddRemote, ConanAddUser, InitConanClient,
    MavenDescriptorStep, RunConanCommand, ansiColor, ansiblePlaybook,
    archive...</p>
  </blockquote>
  
  <p>As far as I understand, I've imported the git package into the pipeline so I don't understand why this function is not recognized.</p>
  
  <p>Another problem I have is that the pipeline only "looks" at the <code>standardPipeline.groovy</code> file at <code>projectDir/vars</code> and not under <code>src/com/company/pipelines/standardPipeline.groovy</code> ... I even tried removing the vars dir but the pipeline keeps looking there... why is that?</p>
  
  <p>Any idea what I'm doing wrong?</p>