title: Jenkins pipeline groovy testing in shell
body: <p>Can jenkins pipeline scripts be tested using <code>groovysh</code> or <code>groovy scriptname</code> to run tests for validation without using the Jenkins UI</p>
  
  <p>For example for a simple script</p>
  
  <pre><code>pipeline {
    stages {
      stage ('test') {
        steps {
          sh '''
          env
          '''
         }
      }
    }
  }
  </code></pre>
  
  <p>running a test like this, depending on the subset of scripting gives:</p>
  
  <p><code>No signature of method: * is applicable for argument types</code></p>
  
  <pre><code>groovysh_evaluate.pipeline()
  </code></pre>
  
  <p>or for
      stage('test'){
         sh '''
         env
         '''
      }</p>
  
  <p>reports:</p>
  
  <pre><code>No signature of method: groovysh_evaluate.stages() 
  </code></pre>
  
  <p>or simply</p>
  
  <pre><code>   sh '''
     env
     '''
  </code></pre>
  
  <p>reports:</p>
  
  <pre><code>No signature of method: groovysh_evaluate.sh()
  </code></pre>
  
  <p>The question may be which imports are required and how to install them outside of a jenkins installation?</p>
  
  <p>Why would anyone want to do this?</p>
  
  <p>Simplify and shorten iterating over test cases, validation of library versions without modifying jenkins installations and other unit and functional test scenarios.</p>