title: How to access pipeline DSL in groovy classes(and not in Jenkinsfile)?
body: <p>I want to access pipeline steps like 'bat' or 'echo' in my groovy classes but I am not really aware of how the 'script' variable usage works. This is very small repository with only this class and I am calling this class in groovy test(spock test). Can somebody please enlighten me on correct usage of 'script' variable and how the call should look like ?</p>
  
  <p>SoftwareInstallation.groovy</p>
  
  <pre><code>class SoftwareInstallation implements Serializable {
    Script script
  
  def runInstallationJar(repoDir){
      def exitValues=[]
      def configFiles=['software1.xml', 'software2.xml']
      configFiles.each {
          def status = script.bat returnStatus: true, script: " java -jar ${repoDir}\\resources\\software.jar --inputxml=${repoDir}\\resources\\${it}"
          script.echo "Return status : ${status}"
          if (status){
              log 'success'
          }else{
              log 'failure'
          }
          exitValues.add(status)
      }
      return exitValues
  }
  </code></pre>
  
  <p>}</p>
  
  <p>ps- I do have a Jenkinsfile but that just contains a gradle call to run tests.</p>